From 0382584a77aed5dc926909b7dad6159ae0757e38 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 20 Apr 2020 13:23:57 -0400 Subject: Added jumping and gun (not functional) --- Assets/Scripts/MouseLook.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Assets/Scripts/MouseLook.cs') diff --git a/Assets/Scripts/MouseLook.cs b/Assets/Scripts/MouseLook.cs index f52f685..3365145 100644 --- a/Assets/Scripts/MouseLook.cs +++ b/Assets/Scripts/MouseLook.cs @@ -6,11 +6,13 @@ public class MouseLook : MonoBehaviour public float mouseSensitivity = 100f; public Transform playerBody; + + float xRotation = 0f; // Start is called before the first frame update void Start() { - + Cursor.lockState = CursorLockMode.Locked; } // Update is called once per frame @@ -18,6 +20,12 @@ public class MouseLook : MonoBehaviour { float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime; float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime; + + xRotation -= mouseY; + + xRotation = Mathf.Clamp(xRotation, -90f, 90f); + + transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f); playerBody.Rotate(Vector3.up * mouseX); -- cgit v1.2.3