The player is in first-person, as humanoid model. To other players, when they look up, their torso rotates slightly vertically. It works the same way when I look down. This can also be observed in the game "Rust", by Garry Newman. Here is my script, that is attatched to the spine.
var speed : float = 5;
var torsoRotation : float = 0;
function Update() {
torsoRotation = Input.GetAxis("Mouse Y") * speed;
Mathf.Clamp(torsoRotation, -90, 90);
transform.Rotate(0, 0, -torsoRotation, Space.Self);
}
It works, except for the clamp. I can infinitely roll my upper body. I am suspicious at the fact that in the inspector, my `torsoRotation` is equal to 0. When I move the mouse up or down fairly quickly, it changes to about 0.5 or 1. When I stop using the mouse, it drifts back to 0. *What is happening*, and *how can I fix it?*
↧