I was trying to do a mouselook script when it happened.Here is the script.
public class MouseLook : MonoBehaviour
{
Vector2 mouselook;
Vector2 smoothV;
public float sensitivity = 5.0f;
public float smoothing = 2.0f;
GameObject character;
// Use this for initialization
void Start ()
{
character = this.transform.parent.gameObject;
}
// Update is called once per frame
void Update ()
{
var md = new Vector2 (Input.GetAxisRaw ("Mouse X"), Input.GetAxisRaw ("Mouse Y"));
md = Vector2.Scale(md, new Vector2(sensitivity * smoothing,sensitivity * smoothing));
smoothV.x = Mathf.Lerp(smoothV.x, md.x, if / smoothing);
smoothV.y = Mathf.Lerp(smoothV.y, md.y, if / smoothing);
MouseLook += smoothV;
MouseLook.y = Mathf.Clamp(MouseLook.y,-90f,90f);
transform.localRotation = Quaternion.AngleAxis(-MouseLook.y, Vector3.right);
character.transform.localRotation = Quaternion.AngleAxis(MouseLook.x, character.transform.up);
}
}
.,
↧