using UnityEngine;
[RequireComponent(typeof(Transform))]
public class Camera_Motion : MonoBehaviour
{
Transform main;
public Transform cam;
Transform camt;
float yaw;
float pitch = 180F;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
main = GetComponent<Transform>();
camt = cam.GetComponent<Transform>();
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxisRaw("Mouse X");
float mouseY = Input.GetAxisRaw("Mouse Y");
yaw += mouseX;
pitch += mouseY;
//pitch += mouseY ;
//pitch = Math.Clamp(pitch,89F,91F);
main.rotation = Quaternion.Euler(0, yaw, 0);
camt.rotation = Quaternion.Euler(pitch, yaw, 180F);
}
}