41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CameraController : MonoBehaviour {
|
|
public GameState GameState;
|
|
public Options Options;
|
|
public Transform BodyTransform;
|
|
public Transform HeadTransform;
|
|
|
|
private PauseMenu Menu;
|
|
|
|
private void Awake() {
|
|
Menu = GameObject.FindGameObjectWithTag("Pause Menu").GetComponent<PauseMenu>();
|
|
}
|
|
|
|
private void Update() {
|
|
if (GameState.Current == State.Playing) {
|
|
Cursor.visible = false;
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
|
|
Vector3 Eulers = BodyTransform.localEulerAngles;
|
|
Eulers.y += Input.GetAxis("Mouse X") * Options.MouseSensitivity * (Options.InvertMouseX ? -1 : 1);
|
|
BodyTransform.localEulerAngles = Eulers;
|
|
|
|
Eulers = HeadTransform.localEulerAngles;
|
|
Eulers.x -= Input.GetAxis("Mouse Y") * Options.MouseSensitivity * (Options.InvertMouseY ? -1 : 1);
|
|
if (Eulers.x > 90 && Eulers.x < 180) {
|
|
Eulers.x = 90;
|
|
}
|
|
if (Eulers.x < 270 && Eulers.x > 180) {
|
|
Eulers.x = 270;
|
|
}
|
|
HeadTransform.localEulerAngles = Eulers;
|
|
} else {
|
|
Cursor.visible = true;
|
|
Cursor.lockState = CursorLockMode.None;
|
|
}
|
|
}
|
|
}
|