|
I'm trying to make a particlesystem appear upon a collision and make it disappear after three seconds. Can I accomplish this using coroutines? The code I have so far (which doesn't work) is: using UnityEngine; using System.Collections;
(comments are locked)
|
|
In your trigger function, you destroy the object first, so anything coming after won't do. Additionally it doesn't matter if you call Destroy before or after starting the coroutine. Destroy is delayed until the end of the current frame. The real problem is that the coroutine runs on this object. When you destroy it, the coroutine will be destroyed as well. You need either an script on another object on which the coroutine can run, or don't destroy this object. You can just disable the renderer so it's not visible anymore. You can destroy it when your coroutine has finished.
Jun 28 '12 at 05:00 AM
Bunny83
I fixed it to make it disappear, and it's working fine. Why is it, though, that it executes the ps.renderer.enabled= true, which is after the destruction of the object?
Jun 28 '12 at 12:59 PM
Dave321
Thanks for pointing that out. I'll leave that there so it won't look like your talking to yourself...
Jun 29 '12 at 03:22 AM
Dave321
(comments are locked)
|
