diff --git a/Assets/Scripts/Input/HerdController.cs b/Assets/Scripts/Input/HerdController.cs index 5753057..7bf95d7 100644 --- a/Assets/Scripts/Input/HerdController.cs +++ b/Assets/Scripts/Input/HerdController.cs @@ -19,7 +19,10 @@ public class HerdController : MonoBehaviour [SerializeField] private float WaitTime; + + private float lastTime; private List Herd; + private Vector2 recievedInput; void Start() { @@ -31,7 +34,11 @@ public class HerdController : MonoBehaviour private void OnMovement(InputValue value) { Vector2 input = value.Get(); - Herd.ForEach(p => p.SetMovement(input)); + if (input.magnitude > 0) + input = input.normalized; + + Herd.ForEach(p => p.SetMovement(input)); + recievedInput = input; } @@ -84,10 +91,24 @@ public class HerdController : MonoBehaviour - Debug.Log("Total Spawned: " + Herd.Count); + } + Debug.Log("Total Spawned: " + Herd.Count); } + public void FixedUpdate() + { + if (recievedInput.magnitude > 0 && lastTime + WaitTime < Time.time) + { + Herd.ForEach(p => p.MoveObject()); + Debug.Log("Time waited: " + (Time.time - lastTime)); + lastTime = Time.time; + + } + + } + + public IEnumerator MoveRoutine() { foreach (PlayerController pc in Herd)