using UnityEngine;
public class PlayerController : MonoBehaviour
{
// Player movement speed
public float walkSpeed = 5f;
public float sprintSpeed = 10f;
private float currentSpeed;
// Mouse sensitivity for looking around
public float mouseSensitivity = 2f;
// Vertical rotation limit for looking up and down
public float verticalRotationLimit = 60f;
private float verticalRotation = 0f;
// Player jump force
public float jumpForce = 5f;
// Player gravity
public float gravity = -9.8f;
// Character controller component
private CharacterController characterController;
// Player velocity
private Vector3 playerVelocity;
// Animator component
private Animator animator;
private void Start()
{
// Get the CharacterController component
characterController = GetComponent<CharacterController>();
// Get the Animator component
animator = GetComponent<Animator>();
// Lock the cursor to the game window and hide it
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
// Set the initial speed to walk speed
currentSpeed = walkSpeed;
}
private void Update()
{
// Player movement