|
I have a script that I'm trying to use to track when a player goes out of the map's bounds. If the player doesn't get back in bounds in ten seconds his unit is destroyed. The script works when the player goes out of bounds, but the IEnumerator doesn't stop when he returns to the map. The bounds is just a box trigger, when the player exits it starts the coroutine, and when he enters I need it to stop the coroutine. Thank you.
(comments are locked)
|
|
It's not an IEnumerator. The IEnumerator is the return type of the co-routine. You want to stop the coroutine. You have the co-routine that does the following:
Your co-routine has nothing to stop it until it kills the character and a loop that can do it multiple times. Try to understand what your code is doing as this lack of understanding is the cause of most difficulties. To do what you're describing, try doing something like: Thank you. All I needed was the break statement. The way the rest of my project is structured it will only kill him once, not multiple times.
Sep 23 '10 at 03:19 PM
mlkielb 1
Then why do you have that while loop while(status.outOfBounds == true) if you're only doing one iteration of the loop?
Sep 24 '10 at 02:50 PM
skovacs1
(comments are locked)
|
|
You can use StopCoroutine to cancel an existing coroutine, but it must be started using the string version.
(comments are locked)
|
|
Or you use StopAllCoroutines() to kill all on that GO
(comments are locked)
|
