- Home /
Question by
Antonc13 · Jan 16, 2021 at 10:30 PM ·
rotationquaternionslerp
Quaternion Problem
Hello Peoples of Unity, I'm having an issue with some of my code regarding quaternion rotation. In my code im trying to get my gun object to point towards a target only on the x-axis. Right now I have it for each x, y, and z axis, how would I go about only rotating the x-axis and also clamping its values?
void GunRotate()
{
{
//Handles Rotating the Calibrator
direction = (player.position - gun1.position).normalized;
lookRotation = Quaternion.LookRotation(direction);
Quaternion rotater = Quaternion.Slerp(gun1.rotation, lookRotation, Time.deltaTime * rotationSpeed);
gun1.rotation = rotater;
}
{
//Handles Rotating the Calibrator
direction = (player.position - gun2.position).normalized;
lookRotation = Quaternion.LookRotation(direction);
Quaternion rotater = Quaternion.Slerp(gun2.rotation, lookRotation, Time.deltaTime * rotationSpeed);
gun2.rotation = rotater;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613023424im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Quaternion Slerp help 1 Answer
Get slerp to work just as LookAt(,Vector3.right) does 1 Answer
How to smoothly rotate an object on only two axes? 2 Answers
Quaternion.Slerp on local axis 1 Answer