- Home /
The question is answered, right answer was accepted
(s)lerp y-rotation to the direction of velocity
Hi all
I'm facing this problem here that I can't resolve. My car-type object moves and can jump on the local y-axis. When it is on a steep slope and it jumps, I want it to (slightly) face the direction of the velocity by changing the y-rotation.
Thanks for your help, I appreciate it
Greets, Senne
I need a diagram or some more information here. It can jump on the 'Y' axis, but if it is jumping on the 'Y' axis, then you would not be changing the 'y' rotation if you want it to face in the direction of the velocity. You would be changing the 'x' or the 'Z' rotation. Plus what does 'slightly' mean and how is it measured?
Answer by sdp · Jun 26, 2013 at 10:02 AM
I already found a solution
if (!grounded) {
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(Vector3(rigidbody.velocity.x, 0, rigidbody.velocity.z)), Time.deltaTime/faceFactor);
}
Follow this Question
Related Questions
Changing rotation of Quaternion 0 Answers
Rotation resets? 1 Answer
How do I transition smoothly between two lerps/slerps? 1 Answer
Lerp/slerp to smooth camera 1 Answer