Switch gravity button

i’m making my first game , a simple one where you tap to change gravity and avoid obstacles
i want to make it so the player switch gravity on mouse touch ( when he’s down he goes up and when he’s up he comes back down )
the problem is i cant find a way to seperate these behaviors , when i click both behaviors get triggered and the player stays on its place
i tried with variables and booleans but i cant get it right

what would be the correct way to do this

use a variable
at beginning of scene could be 0
when you touch if variable is 0 you change gravity to go up and set vsriable to 1
if you touch again variAble value is 1, so you change gravity and variable value to 0 again

i tried that but couldn’t get it right
but thanks for letting me know that it’s possible this way , i’ll just keep tweaking it till it works

If both behaviours get triggered, it probably means you don’t have enough conditions in place.

i did it kind of
however there’s still something that i don’t get
i set a condition to on mouse click pressed and set it to trigger only once but the behavior keeps reoccuring , any idea why this happens ?

can you show the fragment of code?

A behaviour doesn’t “reoccur”, it’s either enabled or disabled. Unless you disable it, it remains enabled.

1 Like