0 votes

Hello guys, I ran into a little problem: I want to direct an instanced missile towards an object moved by the player, the problem is that I calculated the direction (i.e. object position - missile position) and since the missile is a 2D kinematic body I inserted the moveandslide(direction * speed) method to make it move towards the player by inserting everything in physicsprocess() but the result is that the missile moves but to a different place. I don't know what to do except that it occurred to me that it is perhaps a problem of angle calculation... if you can help me...

Godot version 3.2.3
in Engine by (54 points)

1 Answer

+1 vote

There is a Vector2.direction_to() method. Have a look.
All it does is calculate (b - a).normalized(). You were doing it backwards.

by (8,152 points)
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 [email protected] with your username.