// Original code by Taylor
// https://biotechgames.itch.io/lost-footage
// In The Empty: Lost Footage
// DO NOT edit OR distribute
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerTransform;
public GameObject torchlight;
float xRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
if(playerTransform.gameObject.GetComponent<PlayerMovement>().isEnabled == true)
{
float xRot = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float yRot = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= yRot;
xRotation = Mathf.Clamp(xRotation, -90, 90);
playerTransform.Rotate(Vector3.up * xRot);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
}
torchlight.transform.rotation = Quaternion.Lerp(torchlight.transform.rotation, transform.rotation, 1);
}
}