Variable not updating/ goes to 0

Hello, Eranwel

My guess it’s because you are changing the damage in event ABOVE of the event that’s shooting the FireBolt. The Gdevelop reads the events from top to the bottom. If your FireBolt colision with your enemy in the same frame that was created the damage the change will not have been applied yet because that event has “passed”.

Try to remove the event with “Trigger once” and take this action and put after the action thats firing the FireBolt.


Thank you so much! It worked!

There is still one issue though. I was trying to set the stats of all fireballs before they are created. Your solution did fixed my main issue, but if i’ll go with this then my game will be applying the stats after each individual fireball is created and won’t be making the fireballs with their stats already set. I don’t know if what I’m talking about is possible or do I need to apply the stats manually in order for the fireballs to be set before their creation.

What event do you use to make the variable Weapons.Fireball.Level of player change from one to 2 to 3 etc? Couldn’t you just change that to variable Weapons.Fireball.Damage and give it a default value of 1, and instead of changing it to level 2 in w/e events does that, you can change it to 1.2, etc. Then just give your fireball a base damage of 10. Then in your damage event (action side) you can say - Change the Damage of Firebolt multiply by player variable Weapons.Fireball.Damage. Not sure what condition you would need to set there to keep it from doing that constantly even when there are no fireballs on the screen, because I haven’t used the extension. You could try Number of fireball > 0 or something.

I’m sorry, I didn’t understood anything you said…

I was wondering if you could stop changing the players fireball level. And instead change the players fireball damage multiplier.

Because the player will not know how the code works I think it don’t make difference if will change before or after :thinking: But if you prefer it that way, I think I can help you. :wink:

You are using an Object Variable for “Damage”. When you change this through events you are changing the instances of this object. You are not changing the Object Variable itself. The Object Variable itself remais the same valor and the new instances will be created with that valor. I don’t know if is possible to change the Object Variable itself through events. I think it’s not.

So, I would suggest you to use a scene variable (maybe a global if you want to use this through scenes) for your “Damage”. Because the scene variable does not match any object instance you can change it before creating the firebullets. But don’t forget to make the necessary changes in your events that’s applying the damage in your enemies with your new scene variable.

Edit: I made some changes to try to make my explanation better. :eyes:

1 Like

Lucky-j, I don’t think I can, coz each weapon has levels that change the weapon’s stats like damage, movement speed or even the effects of the weapon. I did something inspired by your comment though:

Rasterisko, thank you so much for your insight! I wanted to set the fireball’s damage before it gets created to decrease potential performance issues or potential bugs, but i think it’ll be fine as you suggested. I showed what i did in reply to Lucky-j’s comment, it’s basically what you suggested, i think. If there’s something I could do for you, let me know. I don’t have a lot of time nowadays, but maybe I could do something simple.

1 Like

Hahaha, you don’t have to worry about it! Lots of people help me here on the forum too! :handshake:

1 Like