(2D) Face Object in Direction of Travel

I have a turret which fires a projectile, that when it collides with a certain object (namely a shield attached to the player), it will bounce off using the unity physics material “bouncy” setting. The problem, however, is the projectile does not rotate in the direction it is traveling (it’s a laser, if that helps you visualize it). I have done much research to try and find how to solve this, but much of it does not translate into 2D. Does anyone with experience in 2D know how I can solve this problem?

Hi there,

You should make the “forward” vector of your projectil, match the direction of the movement.

That way, your projectil will look always in the direction of the movement.

You can achieve this by accessing the transform.forward property:

this.transform.forward = this.GetComponent<Rigidbody2D>().velocity;

I am assuming it has a rigidbody attached to it… If not, you will have to find the direction of movement in another way.

Hope it helps.