LookRotation in 2D

How do I rotate a 2D rigidbody along its trajectory?

obj.rotation = Quaterion.LookRotation (obj.velocity) doesn’t work that way.

Ehm. It’s 2D. :slight_smile:

Why do I recieve a error then?

Cannot implicitly convert type UnityEngine.Quaternion' to float’

Oh, I get it. Had to write obj.transform.rotation instead of just obj.rotation

Though the object disappears now for some reason. What am I doing wrong? :face_with_spiral_eyes:

Well, it’s 2D. :wink:
The only axis you can rotate a 2D object around is the one that is perpendicular to the x/y axis. That’s usually z.
“rotate along its trajectory” would be rotating it around its x or y axis.

Or is this request just about rotating a 2D object to the direction that it moves to?

Yep, it is.

Oh, ok. Pardon! I guess this post describes what you’re looking for.

1 Like