Сделал базовое управление машиной и персонажем
This commit is contained in:
1 parent
10d42b72b8
commit
48753f65fb
152 files changed
+15117
-174
No files matched your search
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerInputHandler : MonoBehaviour
|
||||
{
|
||||
[Header("Components")]
|
||||
[SerializeField] private PlayerMovement playerMovement;
|
||||
[SerializeField] private PlayerLook playerLook;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
HandleMovementInput();
|
||||
HandleLookInput();
|
||||
}
|
||||
|
||||
private void HandleMovementInput()
|
||||
{
|
||||
// Читаем оси WASD. GetAxisRaw дает более резкое, отзывчивое управление без инерции.
|
||||
float horizontal = Input.GetAxisRaw("Horizontal");
|
||||
float vertical = Input.GetAxisRaw("Vertical");
|
||||
|
||||
// Нормализуем вектор, чтобы игрок не двигался быстрее по диагонали
|
||||
Vector2 moveInput = new Vector2(horizontal, vertical).normalized;
|
||||
|
||||
if (playerMovement != null)
|
||||
playerMovement.ProcessMove(moveInput);
|
||||
}
|
||||
|
||||
private void HandleLookInput()
|
||||
{
|
||||
// Читаем движение мыши
|
||||
float mouseX = Input.GetAxis("Mouse X");
|
||||
float mouseY = Input.GetAxis("Mouse Y");
|
||||
|
||||
Vector2 lookInput = new Vector2(mouseX, mouseY);
|
||||
|
||||
if (playerLook != null)
|
||||
playerLook.ProcessLook(lookInput);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user