Object doesn't move when clicked on

I have a problem with my game…

When I click on an object, its ‘moving’ variable is set to 1 (0 by default). I have an event that says when an object’s ‘moving’ variable is 1, add a value to its Y position (i.e. move it down the screen). However, this doesn’t work.

As my game has a lot of other events and stuff going on, I’ve been able to re-create just this issue in the attached demo. I added an action to change the object’s opacity, so I could see that the click event works (which it does), but the movement itself doesn’t (my computer fan starts whirring quite loudly after I click on the object, which makes me think there’s an issue with it trying to do too much, but I can’t work out what).

Any assistance appreciated!
game.json.zip (1.72 KB)

You want to use a While loop only if you want the program flow to STOP while a certain condition is true and repeat a certain action over and over again, like count to 10 before continue and such. Need to be careful with it, the While loop can cause some weird behaviour. In your case what is happening, the program flow is stopped and you do update the Y positon of the object but it is never going to be updated on the screen because you never exit the loop.
Add a sub-event to the while loop to set moving to 0 if the object Y position is greater than something but then what you going to see the object is jump from it current position to it final position. Maybe this is not what you intended.

If you want the object to fall, put the condition and action in to a standard event and it should work.
In most cases, a standard event is fine don’t need to over complicate it.

Thanks! That makes sense. I didn’t realise that’s how while loops work in GDevelop, good to know.
I’ve also updated my game to use a movement system that doesn’t rely on a while loop, as suggested :slight_smile: