From 39cb427954535bb0cfb562ef91d9865acee39896 Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Sat, 1 Feb 2020 15:41:31 +1100 Subject: [PATCH] Made a more regular move time --- Assets/Scripts/Input/HerdController.cs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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)