I'm trying to create a top-down space shooter like Asteroids, where all of the ships are RigidBodies. I want to make it so that the enemies always turn to face the player, which is done through the below code:
var player_vector = (player.position - position).normalized()
set_applied_torque((rad2deg(player_vector.angle()) - rotation_degrees + 90) * spin_speed)
For the most part, this works fine. Unless the player is to the lower-left of the enemy, in which case the enemy begins to spin uncontrollably,
First of all, is this the best way to implement this sort of behavior? If so, what am I doing wrong? If not, what is the best way to do this?