Puzzled by touch/cursor

I’m trying to make it so if a player clicks/touches on the left side of the screen above the player, the player moves up, and below the player, the player moves down. But for some reason, only the up is working.

Here’s what I’ve got…

Even more puzzling, if I toggle disabled on the up events, then the down events will work.

[edit]I’ve also tried it like this

and like this

Same effect of the up works but the down doesn’t.

Now I tried this:

And I got a different result, but not what I was hoping for. The above set of events just pushes the player object into the top left corner.
(edit) there’s a typo in the above events. Should be cursorY position does not = 0; I fixed it, still same effect.

Well after trying a half dozen different solutions I think I stumbled upon something that works. I think trying to put the LastTouch and Cursor positions together with “OR” was confusing the game engine. When I separated them, it worked the way I wanted. Now I just need to test it on mobile :slight_smile:

Here’s the one that worked.


The OR is tricky, better stay away from it, if possible.
Great that you solved your issue yourself. :clap:

1 Like

What led me to trying the OR in the first place was the condition in GDevelop is “Touch or Mouse button is down” so I was trying to find a way to distinguish between them so it would work in both conditions in as few events as possible.

I wonder if it would be an improvement to have a separate condition for touch and mouse? So we had an option for “Touch is down” and another option for "Mouse button is down. Or if it would be difficult/impossible for reasons I don’t understand.

You should be able to differentiate both using the condition “device is mobile”, inverted or not.

1 Like