0 votes

Hi there!

I've been struggling with getting movement in 3d top-down to work, I want the "player" to follow the touch on the screen, I've tried a lot of things to get this to work to no avail.
But I had an idea and I don't know if Godot even supported such a thing.
using distance_to I want to find how far away the curser is from my anchor, but it works as shown below
https://imgur.com/a/wI5oJKv

is most cases this is how you want it to work but in my case I don't.
I want it to work more like it is shown below
https://imgur.com/a/ioMWkFv

if you can help me thank you so much!

Godot version Godot v3.4.4
in Engine by (60 points)

1 Answer

0 votes
Best answer

Perhaps I'm missing something, but:

distance = abs(position_A.x - position_B.x)

If that's not what you want you can always call distance_to() with some extra steps:

var pos_a = Vector2(position_A.x , 0)
var pos_b = Vector2(position_B.x , 0)
distance = pos_a.distance_to(pos_b)
by (191 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.