Skip to main content
added 2 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from beggingbeginning of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

Another example with coroutine even more elegant:

public List<GameObject> minions = new List<GameObject>(); void Start() { StartCoroutine(SendOneMinion()); } private IEnumerator SendOneMinion() { foreach (GameObject mn in minions) { yield return new WaitForSeconds(3); mn.GetComponent<WaypointsFollower>().GoRightNow(); } } 

here coroutine is running, and inside a loop there is 3 second delay before sending new minion..

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from begging of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

Another example with coroutine even more elegant:

public List<GameObject> minions = new List<GameObject>(); void Start() { StartCoroutine(SendOneMinion()); } private IEnumerator SendOneMinion() { foreach (GameObject mn in minions) { yield return new WaitForSeconds(3); mn.GetComponent<WaypointsFollower>().GoRightNow(); } } 

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from beginning of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

Another example with coroutine even more elegant:

public List<GameObject> minions = new List<GameObject>(); void Start() { StartCoroutine(SendOneMinion()); } private IEnumerator SendOneMinion() { foreach (GameObject mn in minions) { yield return new WaitForSeconds(3); mn.GetComponent<WaypointsFollower>().GoRightNow(); } } 

here coroutine is running, and inside a loop there is 3 second delay before sending new minion..

added 1 character in body
Source Link
ShoulO
  • 509
  • 2
  • 6

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from begging of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

*Another example with coroutineAnother example with coroutine even more elegant:

public List<GameObject> minions = new List<GameObject>(); void Start() { StartCoroutine(SendOneMinion()); } private IEnumerator SendOneMinion() { foreach (GameObject mn in minions) { yield return new WaitForSeconds(3); mn.GetComponent<WaypointsFollower>().GoRightNow(); } } 

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from begging of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

*Another example with coroutine even more elegant:

public List<GameObject> minions = new List<GameObject>(); void Start() { StartCoroutine(SendOneMinion()); } private IEnumerator SendOneMinion() { foreach (GameObject mn in minions) { yield return new WaitForSeconds(3); mn.GetComponent<WaypointsFollower>().GoRightNow(); } } 

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from begging of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

Another example with coroutine even more elegant:

public List<GameObject> minions = new List<GameObject>(); void Start() { StartCoroutine(SendOneMinion()); } private IEnumerator SendOneMinion() { foreach (GameObject mn in minions) { yield return new WaitForSeconds(3); mn.GetComponent<WaypointsFollower>().GoRightNow(); } } 
added 362 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from begging of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

*Another example with coroutine even more elegant:

public List<GameObject> minions = new List<GameObject>(); void Start() { StartCoroutine(SendOneMinion()); } private IEnumerator SendOneMinion() { foreach (GameObject mn in minions) { yield return new WaitForSeconds(3); mn.GetComponent<WaypointsFollower>().GoRightNow(); } } 

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from begging of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

First: are you sure that you set different value of variable delay for each object/ minion?? Because problem is here: Time.time is a number of seconds that has passed from starting the game. So it will be the same for all objects! So if all minions has variable delay set to 3, and Time.time is equal thought the game - means after 3 seconds Time.time+3 will be exactly equal to each object/minion!

In short, your problem is that you are counting time from begging of the game, which is equal to all objects.

Second: When I want to delay something I almost always use Coroutines. You can specify the time for delay, and since they are asynchronous, so each object can have its own timer running - independent of each other. Also you can start Coroutines and stop them.

Over the time I found that often even more convenient (less code) is InvokeReapeating or just Invoke - you specify time when to fire a function, and that's it. And again each object can have its own timer. You can also CancelInvoke to stop it from firing.

Update() timers gets messy, especially if a lot is happening inside Update() function.

P.S. I do not normally use Update(). In most cases of delays, waypoints, cooldowns, respawns, etc.- Coroutines or InvokeRepeating or Invoke do the job brilliantly, without affecting the rest of the code.

Here would be example of code sending different minion every three seconds: In your main or manager script you write:

public List<GameObject> minions = new List<GameObject>(); void Start() { InvokeRepeating("SendOneMinion", 3, 3); } int i=0; public void SendOneMinion() { if (i< minions.Count && minions[i]!=null) minions[i].GetComponent<WaypointsFollower>().GoRightNow(); else CancelInvoke(); i++; } 

Is not that elegant? All you need to do is to add minions to the list. And oh create function GoRightNow() in each minion script..

*Another example with coroutine even more elegant:

public List<GameObject> minions = new List<GameObject>(); void Start() { StartCoroutine(SendOneMinion()); } private IEnumerator SendOneMinion() { foreach (GameObject mn in minions) { yield return new WaitForSeconds(3); mn.GetComponent<WaypointsFollower>().GoRightNow(); } } 
added 20 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
deleted 8 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 4 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 126 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 509 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 509 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 5 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 101 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 101 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 101 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
deleted 109 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
added 218 characters in body
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading
Source Link
ShoulO
  • 509
  • 2
  • 6
Loading