Unity2D, How do i check which way a sprite is facing?

In the game im creating, the enemies can only move forward and apply torque to turn(i know how to do this). What i need to do is find out which way the sprite is facing so i can add logic to decide whether the AI applies torque in the correct direction or moves forward.

Do you actually want to apply torque? Do you need the physics. In many 2D games you may be better off making your objects kinematic and using angles etc.

Anyway, if you DO need the physics, then I think you want to look at using transform.forward. This will return a vector which gives the forward facing direction of your enemy. Compare that to whatever angle is relevant and then apply logic accordingly.

e.g. (pseudo-code)

if enemy’s transform.forward is towards the player, keep moving forward.
If enemy’s transform.forward is not towards player, then turn clockwise to face them.


Does that help?