29 lines
811 B
C#
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();
|
|
}
|
|
}
|
|
}
|
|
} |