Newer
Older
CGTrack / Assets / Scripts / Bausatz / FPVCamera.cs
@Pascal Syma Pascal Syma on 25 Jul 2021 559 bytes Initial Commit
using UnityEngine;

namespace Bausatz
{
    public class FPVCamera : MonoBehaviour
    {
        public float speedH = 2.0f;
        public float speedV = 2.0f;

        private float yaw = 0.0f;
        private float pitch = 0.0f;

        private void Update () {
            
            Cursor.lockState = CursorLockMode.Locked;
            yaw += speedH * Input.GetAxis("Mouse X");
            pitch -= speedV * Input.GetAxis("Mouse Y");

            transform.localEulerAngles  = new Vector3(Mathf.Clamp(pitch, -90, 40), yaw, 0.0f);
        }
    }
}