Problem with angular vector direction godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Peppe

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 move_and_slide(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…

:bust_in_silhouette: Reply From: exuin

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