|
|
@ -19,7 +19,10 @@ public class HerdController : MonoBehaviour |
|
|
|
[SerializeField] |
|
|
|
private float WaitTime; |
|
|
|
|
|
|
|
|
|
|
|
private float lastTime; |
|
|
|
private List<PlayerController> Herd; |
|
|
|
private Vector2 recievedInput; |
|
|
|
|
|
|
|
void Start() |
|
|
|
{ |
|
|
@ -31,7 +34,11 @@ public class HerdController : MonoBehaviour |
|
|
|
private void OnMovement(InputValue value) |
|
|
|
{ |
|
|
|
Vector2 input = value.Get<Vector2>(); |
|
|
|
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) |
|
|
|