Hi, I created 2 object variables: “Armatura” (armor) e “Energia” (energy).
This is what I would like:
When the player have a collision with energy… the “Energia” increase +1 and when the value arrive to 5 the variable “Energia” came back to 0 and in the same time the variabile “Armatura” increase +1… and then if I press “Space” and the variable “Armatura” is > 0 the variable “Armatura” decrease -1
Really this is what happens:
I pressed the “Space” button and the “Armatura” decrease -1 and is ok.
So for example I start with “Armatura” = 3 press “Space” and “Armatura” = 2
Then I take 5 energy so The “Energia” go to 0 istead my “Armatura” arrive to 3… but when I press again the “Space” button the value in “Armatura” is 1 and not 2… why?
This is my first game and sorry for my english not good.
Thanks for all.
You events look like they should work. My only guess is that the removal of the timer fro memory may not happen instantly, and so that event gets triggered twice.
My suggestion would be to add a “Trigger once while true” condition to the each of the last 2 events.
Hi maybe id for the variable types,
Did you check the variable types all your variables in this case must be type number, just check in your array or collection click on the wrench and set the type to number.
GDevelop loosely types it’s variables, so this won’t matter. It can switch from number to string (and boolean) and back, as long as the value is valid for the type.
Thamks, but so? Because not change nothing… there is the same problem!
Thanks, before I type the value and then I discovered that was string so I changed but not work
Thanks, exactly I tryed before and nothing and then I changed to integer but not change
If the trigger once didn’t fix it, then I suspect you’re modifying or setting the variable somewhere other than the events in your screen snip.
No, the variable is used only in this part of code.
I setted my variable in to the player. I put value= 3, but I tryed also to set it in the beginning scene (0 in the object and 3 in the start) but nothing.
Now I finded an alternative solution different of mine. I divided the two beahviors: on one side with space pressed I substract 1 in my armour and in the other side when my player take 5 energy automatically put the armour… and so it work because I don’t work with the same variable “Armatura”.