Files
gpd-924-en/SOLID/Assets/Scripts/Solid/PlayerInput.cs
T
david a4f498a33d add unity project
add SOLID examples
2025-04-09 07:49:12 +02:00

29 lines
811 B
C#

using System;
using UnityEngine;
namespace DefaultNamespace.Solid
{
public class PlayerInput : MonoBehaviour
{
[SerializeField] private float _speed = 10.0f;
[SerializeField] private float _rotationSpeed = 60.0f;
public Vector3 Movement { get; private set; }
public float Rotation { get; private set; }
public event Action IsFired;
public void HandleInput()
{
Movement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
Movement *= _speed * Time.deltaTime;
Rotation = Input.GetAxis("Mouse X") * _rotationSpeed * Time.deltaTime;
if (Input.GetButtonDown("Fire1"))
{
IsFired?.Invoke();
}
}
}
}