- Home /
Question by
NathanJaremko · Jul 30, 2012 at 10:31 PM ·
2drotationvelocity
Rotating gameobject to velocity
Hello, I'm currently making a game where I need to bounce off the wall and rotate a 2d plane to follow the direction its traveling in (rotation on the z axis). Any help is appreciated.
Comment
Answer by ScroodgeM · Jul 30, 2012 at 10:43 PM
attach script (C#) with this
void Update() { transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(rigidbody.velocity, Vector3.up), Time.deltaTime * 10f); }
to object you need to rotate. object should have rigidbody to take velocity from it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613074936im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D Geometry dash-like ship physics 0 Answers
2D sprite rotation with velocity and interpolation 1 Answer
Unity C# 2D Adding Velocity on rotation 1 Answer
Movement Relative to Rotated Parent 1 Answer