Open hidehub opened 3 years ago
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Camera : MonoBehaviour { public float lookSens; public float minXLook; public float maxXLook;
public Transform anchor;
private float curXRotation;
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
private void LateUpdate()
{
float x = Input.GetAxis("Mouse X");
float y = Input.GetAxis("Mouse Y");
transform.eulerAngles += Vector3.up * x * lookSens;
curXRotation -= y * lookSens;
curXRotation = Mathf.Clamp(curXRotation, minXLook, maxXLook);
Vector3 clamedAngle = anchor.eulerAngles;
clamedAngle.x = curXRotation;
anchor.eulerAngles = clamedAngle;
}
}
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Player : MonoBehaviour { public float speed; public float jumpForce; private float gravity = -9.81f; private bool gravityInvers = false;
}