- Home /
How do I rotate a transform to align with a velocity vector?
I've read several answers that sort of address this question and have a sorta kinda understanding of the math. What I can't figure out is how to code it. To make sure I'm being clear on the objective:
Given transform A with rotation of x rad, y rad and z rad and given velocity vector x,y,z,
how do I rotate transform A such that it's rotation matches the vector? I would like to do this with an iterated procedure such that the transform is actually turning to line up with the vector, not just "snap" to it.
The part that kind of stops me cold is when the word "quaternion" shows up.
Any thoughts much appreciated.
Answer by Berenger · Jan 09, 2015 at 11:35 AM
Try : transform.forward = Vector3.Lerp(transform.forward, rigidbody.velocity, Time.deltaTime * speed);
This looks more like something for translation rather than rotation?