Alright, I've got this code here:
var speed : float = 5;
var torsoRotation : float = 0;
function Update(){
torsoRotation = transform.Rotate(0, Input.GetAxis("Mouse X") * speed, 0, Space.World);
Mathf.Clamp(torsoRotation, -30, 30);
}
This is the error I get in Unity:
Assets/Scripts/mouseRotate.js(5,35): BCE0022: Cannot convert 'void' to 'float'.
I have a full player model. I was trying to get the torso to rotate slightly left and right, as I moved the mouse those directions in first-person. (Just a little bit of realism.) It worked! I added a variable to store the rotation in, and then I clamped it, so it would not rotate infinitely. Then, **it did not work.**
Of course, my logic is probably completely wrong. Is anyone able to explain what I did wrong? Am I unable to store the rotation?
↧