wip: PlayerMover
This commit is contained in:
13
Assets/_Content/Scripts/CameraFollower.cs
Normal file
13
Assets/_Content/Scripts/CameraFollower.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteAlways]
|
||||
public class CameraFollower : MonoBehaviour
|
||||
{
|
||||
public GameObject Player;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Player)
|
||||
transform.position = Player.transform.position;
|
||||
}
|
||||
}
|
||||
2
Assets/_Content/Scripts/CameraFollower.cs.meta
Normal file
2
Assets/_Content/Scripts/CameraFollower.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ae4fbdc595247448b3d604825bd07fe
|
||||
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
|
||||
|
||||
|
||||
}
|
||||
2
Assets/_Content/Scripts/PlayerMover.cs.meta
Normal file
2
Assets/_Content/Scripts/PlayerMover.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 502392351c6ed7e4c9a3a895792f5b68
|
||||
Reference in New Issue
Block a user