- Home /
Slerp Z and X axis only
fromRotation = transform.rotation;
toRotation = Quaternion.FromToRotation(Vector3.up,((hoverGroundHit[0] + hoverGroundHit[1]) / 2));
transform.rotation = Quaternion.Slerp(fromRotation, toRotation, groundRotationSpeed * Time.deltaTime);
How would I make the Slerp rotation only apply to the X and Z axis?
Comment
Answer by sparrow · Oct 12, 2012 at 09:21 PM
You can use Quaternion.Euler to get your rotation in Euler angles representation. And then do something like this:
fromRotation = transform.rotation;
toRotation = Quaternion.FromToRotation(Vector3.up,((hoverGroundHit[0] = hoverGroundHit[1]) / 2));
OriginalY = toRotation.eulerAngles.y; // Save the Y
Vector3 finalRotation = Quaternion.Slerp(fromRotation, toRotation, groundRotationSpeed * Time.deltaTime).eulerAngles;
finalRotation.y = OriginalY; // Set the Y back
transform.rotation = Quaternion.Euler(finalRotation);
Your answer
Follow this Question
Related Questions
itween path restrict rotation on TWO axis 0 Answers
Defining specific controls for rotation. 0 Answers
Problems with rotating and slerp 0 Answers
Lookat via Single Axis 0 Answers