How do I make movement natural with touch?

I’m playing a game like Vampire Survivor on mobile and want to move the player in any direction with just a touch. Is it possible to do this naturally? Using top-down movement, it looks unstable when moving diagonally. Is there a way around this?

Can you explain more what you mean by natural movement? Also what’s the problem with the diagonal movement? I never had problems with the top-down movement behavior. It would help to see the actual problem.

I want to create a player that can move in any direction with the touch of a finger, like in the 1945 flight shooter. I’ve applied top-down movement to the player and referenced the wiki material for events, but I don’t think I’m doing it right somewhere.

As I can tell from seeing a video of the 1945 flight shooter game, the ship is moved by touching anywhere on the screen then dragging.

Here’s how you can achieve this:

1. Remove the simulate controls for touch.
2. Add the sticker behavior to the ship.
3. Create an object (I called it Control) that will control the movement of the ship.

Here’s the event:

Wow, thank you for resolving the issue. It works just as I wanted it to. I have so much to learn…thanks!!!

Great!

Right now the ship can go outside the screen, so if you want to limit the movement to the bounds of the screen, here are the updated events:

1 Like

Perfect!!! I will put it to good use.

1 Like

Your original solution looked like it should work, I’m just not sure why it wasn’t working properly when moving diagonally. This makes me think there was something else going wrong.

However, if you want absolute movement, I would recommend using forces based on the mouse drag:

I have made three scene variables here, oldX, oldY, and MouseFactor. The MouseFactor is there to make the object move more quickly since dragging it one pixel at a time is too slow if your resolution is high enough. I’m simply adding a force based on the X and Y change in the mouse position, multiplied by the MouseFactor. Then update oldX and oldY to the current mouse position before the end of the events (but after detecting movement).

I would prefer this to Stickering since you can control the speed of movement, and you can have other forces that affect the player in a more natural way.

One other slightly unrelated thing, but I would remove the “is a touchscreen” condition entirely, so that players on PC can use the mouse if they want to.

Good luck!

Both are the same solution and work fine, I tested them while working out the solution. I just added boundaries so that the ship doesn’t go off-screen in the second post.

Your solution is good and simple. However IMO, I don’t think it would be a more natural movement to have the ship move slower or faster than the speed of dragging with finger/touch. Having the speed be exactly the same makes the movement more responsive giving the player more control over the movement of the ship.

Maybe for mouse control, the sticker can be replaced with variables and expressions to control the speed, and can be added as an option to adjust the speed in the settings of the game.