Hi there! Im developing with Vuforia AR plugin. I want to Activate an animated gameobject, wait for some seconds and the hide that gameobject and show another one! I tried differents things(invoke, WaitForSeconds, Destroy(GO,time)<= this one runned ok but when I tried to show the GO again obviusly I was in trouble) but I can't make it run the delay. The code:
[ Edit by berenger : trimmed irrelevant code. Full code available at http://pastebin.com/nA3SXHRt]
So, you are not using coroutines correctly.
First, a coroutine will only delay the execution of the code following the yield inside its scope. Wich means that your Delay function exectute the Debug.Log, wait and leave. But Update didn't wait. So the animation was started the stopped at the same frame.
Secondly, in C# you need to call a coroutine with StartCoroutine, or it won't be executed at all.
You can't use Invoke directly because you have a parameter. You could store the animacion variable into a member though. Anyway, for the coroutine. When you have the event triggering the animation, use StartCoroutine( Animate(animacion) ); Here is Animate's code :
answered May 03 '12 at 10:50 PM
Hey dear! Lot of thanks for your answer! I tried compiling with this code: http://pastebin.com/NV2aLt5A
But nothing was rendered! So I used debugging logs and I checked that the Animate function never is executed! Any idea??