wip: PlayerMover
This commit is contained in:
53
Assets/_Content/Scripts/PlayerMover.cs
Normal file
53
Assets/_Content/Scripts/PlayerMover.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMover : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
private class Settings
|
||||
{
|
||||
public float Speed = 5;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
private struct References
|
||||
{
|
||||
public CharacterController Controller;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class StateContainer
|
||||
{
|
||||
public bool IsJumping = false;
|
||||
}
|
||||
|
||||
#region FIELDS
|
||||
|
||||
const float MS_TO_KMH = 1 / 3.6f;
|
||||
|
||||
[SerializeField] private Settings _settings;
|
||||
[SerializeField] private References _references;
|
||||
[SerializeField] private StateContainer _state;
|
||||
|
||||
public StateContainer State => _state;
|
||||
|
||||
#endregion
|
||||
|
||||
#region UNITY LIFECYCLES
|
||||
|
||||
void Update()
|
||||
{
|
||||
float t = Time.deltaTime;
|
||||
|
||||
Move(t);
|
||||
}
|
||||
|
||||
private void Move(float t)
|
||||
{
|
||||
transform.position += Vector3.forward * t * MS_TO_KMH * _settings.Speed;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user