Can't change rotation?
I'm trying to limit the rotation of a bone but for some reason I just can't set it equal to temp. It's like it's just skipping that line. In the debug log temp is exactly what it should be but the final local rotation hasn't changed. I've tried both setting up a new Quaternion and just simply setting it to temp, but neither are working. Thanks!
headBone.transform.LookAt(thePlayer.transform.position);
//Limit rotation
Quaternion temp = headBone.transform.localRotation;
temp.x = 0.213772f;
if (temp.y > 0.1f) {
temp.y = 0.1f;
}
if (temp.y < -0.1f) {
temp.y = -0.1f;
}
if (temp.z > 0.1f) {
temp.z = 0.1f;
}
if (temp.z < -0.1f) {
temp.z = -0.1f;
}
//This line appears to be getting skipped
headBone.transform.localRotation = new Quaternion(temp.x, temp.y, temp.z, temp.w);
//headBone.transform.localRotation = temp;
Debug.Log("temp: " + temp);
Debug.Log(headBone.transform.localRotation);
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612122605im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to set y rotation of an object to be z rotation of another? 1 Answer
Help limiting Camera rotation, spinning out of control. 1 Answer
Ambient Emitter inside a BoxCollider - Rotation not recognized 0 Answers
How can i rotate an object using LookAt with only 1 axis? 0 Answers
Know when the object is rotated? 1 Answer