- Home /
rotation LookAt of 2D gameObject in 3D space
Hi, I have a 2D gameObject (Vector2 positions, constantly moving up in y-axis). Now I want to turn it in a particular direction, which I got as another Vector2. How do I turn the y-axis in the new direction?
Transform.LookAt and Quaternion.LookRotation doesn't seem to work, as the set the z-axis to look in this direction, which messes everything up. Also they expect Vector3 as input. Any advice? (using javascript)
Answer by ttt81 · Dec 02, 2013 at 04:55 PM
Got it! :D
this.transform.rotation = Quaternion.FromToRotation(Vector2.up, directionVector);
with Vector2.up beeing the fixed local moving direction
Your answer
Follow this Question
Related Questions
2D: Rotating to face mouse position with two fixed axes 1 Answer
Why is my GameObject rotation snapping to a certain angle when he reaches its destination? 2 Answers
[JS] transform.rotation not working 1 Answer
Making the players head face toward the location of the mouse? 1 Answer
Rotate the same way no matter what direction facing? 1 Answer