![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Danicano |
I’ve managed to detect the swipe (start position and end position points).
I’ve managed to calculate the distance between the two points (so the more distance the more speed).
My problem comes when I want to give the direction of the swipe to the player’s movement. I have no clue.
Anyone can throw some light on it?
Thanks.
Since you have acquired the end position, you could have your character point and move towards it by using the look_at()
method. More info here:
2D movement overview — Godot Engine (3.1) documentation in English
Is your game 2D or 3D? Do you have a top-down approach or something else?
johnygames | 2019-08-07 17:50
Thanks for your answer.
The game is 2d.
Yes, I’ve tried the look_at() method, and the player moves towards the end point and it works as expected. The problem is that it is not exactly what I’m trying to achieve, because if I swipe to the left, for example, and the player is placed more on the left of my finger, the player will move right and not left. What I want is the player moving in the same direction of my swipe, no matter where the swipe occurs on the screen. I don’t know if I explain myself well enough…
Danicano | 2019-08-07 18:15