this is the code for rotating spine in my character model:
Transform spine;
float horzMovement;
void Awake() {
spine = transform.Find("Character/Healthmale/Root/pelvis/spine_01");
}
void Update() {
horzMovement = Input.GetAxis("Mouse Y");
}
void LateUpdate() {
spine.localRotation = Quaternion.Euler(
spine.localEulerAngles.x + horzMovement,
spine.localEulerAngles.y,
spine.localEulerAngles.z
);
print(horzMovement + " / " + spine.localRotation.eulerAngles.x + " " + Time.time);
}
Code is quite simple, I'm just rotating "X" axis from y mouse movement. The problem is when running this code, it seems work but it keeps rotating back to the original rotation.
This is the log that I printed into the console. Note that spine's original x rotation is about 27.62928.
0 / 27.69298 4.510662
0 / 27.69298 4.527147
-0.1 / 16.33139 4.543715 // minus movement detected
-0.1 / 16.3314 4.560284
-0.1 / 16.33139 4.57685
-0.1 / 16.33139 4.593714
-0.1 / 16.3314 4.609998
-0.1 / 16.33139 4.626548
-0.1 / 16.33139 4.643115 // but it seems not much changed, why?
-0.15 / 10.51222 4.659858
-0.15 / 10.51222 4.676248
-0.15 / 10.51222 4.692952
0 / 27.69298 4.759083 // this is when I stopped the mouse. It's reset.
0 / 27.69298 4.775648
As you see the above log, first time, it prints 27.692.. and it's original x rotation of spine.
Next, I moved my mouse so the "horzMovement" value was updated to minus, and it updates x localRotation also.
But when I stopped move mouse, it just return to initial x rotation 27.69298!
There is no code or functionality to "rotating back" to original rotation of spine. I don't know why this is happening. Wham am I missing?
Any advice will very appreciate it!!