- Home /
Quaternion.Slerp and Quaternion.Euler problem
Greetings.
I am making a script that uses Quaternion.Slerp command. It works, but I need to constrain the x and z-axis rotation so that only y-axis rotates. I've tried this with Quaternion.Euler but it didn't work. Here is a snippet of my script.
private var speed = 5;
var newRotation = Quaternion.LookRotation(targetObj.position - head.transform.position);
head.transform.rotation = Quaternion.Slerp(head.transform.rotation, Quaternion.Euler(0,newRotation.y,0), Time.deltaTime * speed);
Thank you in advance.
Answer by Yonlop · May 06, 2012 at 11:47 AM
Okay nevermind. I got it. Just specified the x and z initially and it works.
var newRotation = Quaternion.LookRotation(targetObj.position - head.transform.position);
newRotation.x = 0;
newRotation.z = 0;
head.transform.rotation = Quaternion.Slerp(head.transform.rotation, newRotation, Time.deltaTime * speed);
I'm just wondering if there is an overall implication to how the object react to other scripts, but it looks okay for now.
Your answer
Follow this Question
Related Questions
Quaternion.Euler and Quaternion.Slerp problem when using *= Add!! 0 Answers
How can I use lerp to rotate an object multiple times? 2 Answers
Quaternion.Slerp problem... 1 Answer
Choppy rotation of character around y-axis 1 Answer
i want to get my to cube to rotate 90 degrees on the x-axis as it jumps 0 Answers