feat: rotate the player camera to the side with the mouse

This commit is contained in:
2026-02-24 09:33:08 +01:00
parent 227f8bde40
commit 44e13f4837
10 changed files with 1849 additions and 27 deletions

View File

@@ -5,14 +5,30 @@ using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
private InputMaster _inputMaster;
[SerializeField] private CharacterController controller;
[SerializeField] private float speed;
[SerializeField] private float mouseSensitivity = 20f;
[SerializeField] private Transform playerBody;
private float _mouseX, _mouseY;
private Vector2 _moveDirection;
private void Awake()
{
controller = GetComponent<CharacterController>();
_inputMaster = new InputMaster();
_inputMaster.Player.Look.Enable();
_inputMaster.Player.Move.Enable();
}
private void Update()
{
var mousevalue = _inputMaster.Player.Look.ReadValue<Vector2>();
_mouseX = mousevalue.x * mouseSensitivity * Time.deltaTime;
_mouseY = mousevalue.y * mouseSensitivity * Time.deltaTime;
playerBody.Rotate(Vector3.up * _mouseX);
}
public void OnMove(InputAction.CallbackContext context)