Fps Contoller For Unity
Fps Contoller For Unity
Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
float rotationX = 0;
CharacterController characterController;
// Start is called before the first frame update
void Start()
characterController = GetComponent<CharacterController>();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
void Update()
#endregion
#region Handles Jumping
moveDirection.y = jumpPower;
else
moveDirection.y = movementDirectionY;
if (!characterController.isGrounded)
#endregion
characterController.Move(moveDirection * Time.deltaTime);
if (canMove)
playerCamera.transform.localRotation = Quaternion.Euler(rotationX,
0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") *
lookSpeed, 0);
#endregion