8 directions without a joystick on mobile?

Hello.
How do I create the logic to move an airplane by touching the screen in 8 directions without a Multitouch joystick on mobile? I don’t think it’s a draggable behavior because I’m not moving the airplane by touching it directly. I’m hoping to create a “super mario”-like platformer this way. Any help would be greatly appreciated.

I assume that you move your plane by touching at different sides of your mobile,

The key is you have to check the plane x,y positions with where you touch

If touch position x > plane position x → move plane to the right
If touch position x < plane position x → move plane to the left

And with top and bottom too

If touch position y > plane position y → move plane to the bottom
If touch position y < plane position y → move plane to the top


The horizontal touch movement is working, but the vertical touch movement is still not working. What do I need to fix?

The last 2 events both have greater than. One should be less than.

Good! The issue has been resolved. Thank you!

1 Like