Browse Source

Made a more regular move time

master
Joshua Reason 4 years ago
parent
commit
39cb427954
1 changed files with 23 additions and 2 deletions
  1. +23
    -2
      Assets/Scripts/Input/HerdController.cs

+ 23
- 2
Assets/Scripts/Input/HerdController.cs View File

@ -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)

Loading…
Cancel
Save