Quaternion rotation issue please help :'(
I wanted to have my characters spine rotate to the right everytime he aimed, but it is not working. I am pretty sure it is the script because I am not very good with Vector3 and Quaternions. There were no errors in the console after I saved the script either. HipPose is basically when he is not aiming and AimPose is when he is aiming and the spine is rotated to that position.
var HipPose : Quaternion;
var AimPose : Quaternion;
function Start () {
transform.localRotation = HipPose;
}
function Update () {
if(Input.GetButton("Fire2")){
transform.localRotation = AimPose;
}
if(!Input.GetButton("Fire2")){
transform.localRotation = HipPose;
}
}
To what object is this script attached? Do you have an animator component (in which case, that will likely overwrite whatever rotations you're setting)
the script is attached to the spine of my character, the character is rigged w/ animations and has an animator component. Is that the issue?
The first things to make sure of is: if and when those lines are executed. Just add a Debug.Log() call inside of both ifs to see what is happening.
Also you can print out the angles of thise rotations (Debug.Log(AimPose.Euler)) and compare it with the values you want to set from the inspector.
You can also add these lines to the first if to pause the game in the editor, so you can check the current values in the inspector:
if (Input.GetButton("Fire2")) {
transform.localRotation = AimPose;
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPaused = true;
#endif
}
Your answer
Follow this Question
Related Questions
How to use Quaternion.Slerp with transform.LookAt? 3 Answers
Why isn't my steering wheel working? 0 Answers
how to convert a Vector3 to a float value? 1 Answer
Rotate LOCAL y axis to match Joystick input 0 Answers
transform rotation inaccuracy 0 Answers