I’m trying to clamp the camera rotation but when doing so the camera spins out uncontrollably. I tried it with Math.fClamp and another way and both seem to do the exact same thing.
Here is the code that I use:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
float mRotY;
void Start () {
if(rigidbody)
rigidbody.freezeRotation = true;
if(!Debug.isDebugBuild)
Screen.lockCursor = true;
else
Screen.lockCursor = false;
}
void FixedUpdate () {
mRotY = Input.GetAxis ("Mouse Y") * GameManager.sensitivity * Time.deltaTime;
if(mRotY>270.0f)
mRotY = 270.0f;
if(mRotY<90.0f)
mRotY = 90.0f;
//
transform.Rotate(mRotY, 0.0f,0.0f);
}
}