Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (38 sloc) 1.38 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour {
private GameObject cameraTarget;
private Vector3 cameraOffset;
private float rotationSpeed;
private bool enableUpdate;
private float horizontal;
private float vertical;
private CursorLockCheck cursorLockCheck;
private PauseBehaviour pauseBehaviour;
private void Start()
cursorLockCheck = FindObjectOfType<CursorLockCheck>();
pauseBehaviour = FindObjectOfType<PauseBehaviour>();
cameraTarget = GameObject.FindGameObjectWithTag(TagList.Player);
cameraOffset = cameraTarget.transform.position - transform.position;
enableUpdate = true;
void Update()
if (!enableUpdate)
if (cursorLockCheck.Get_CursorActiveState)
if (pauseBehaviour.Get_IsPaused)
horizontal = InputManager.Get_MouseInputX * rotationSpeed;
cameraTarget.transform.Rotate(0, horizontal, 0);
float desiredAngle = cameraTarget.transform.eulerAngles.y;
Quaternion rotation = Quaternion.Euler(0, desiredAngle, 0);
transform.position = cameraTarget.transform.position - (rotation * cameraOffset);
You can’t perform that action at this time.