Files
Praca-MagisterskaMJK/Assets/Scripts/PlayerMove.cs
2026-04-15 23:52:08 +02:00

27 lines
837 B
C#

using UnityEngine;
using UnityEngine.InputSystem; // Dodaliœmy to!
public class PlayerMove : MonoBehaviour
{
public float speed = 5f;
private CharacterController controller;
void Start() => controller = GetComponent<CharacterController>();
void Update()
{
// Nowy sposób pobierania WASD
Vector2 moveInput = Vector2.zero;
if (Keyboard.current != null)
{
if (Keyboard.current.wKey.isPressed) moveInput.y = 1;
if (Keyboard.current.sKey.isPressed) moveInput.y = -1;
if (Keyboard.current.aKey.isPressed) moveInput.x = -1;
if (Keyboard.current.dKey.isPressed) moveInput.x = 1;
}
Vector3 move = transform.right * moveInput.x + transform.forward * moveInput.y;
controller.Move(move * speed * Time.deltaTime);
}
}