Invoking does not work, but why?

private var delayTime       : float = 4;

function Start()
{
InvokeRepeating("animateObject",0,16);
print("started");
yield WaitForSeconds(3);
print("Finish");
CancelInvoke("animateObject");
}

/**function Update () 
{

}**/

function animateObject()
{

print("run");

//animation.Rewind("Rise");
animation.Play("Rise"); 

yield WaitForSeconds(delayTime);

//animation.Rewind("Stand");
animation.Play("Stand");

yield WaitForSeconds(delayTime);

//animation.Rewind("Stand");
animation.Play("Stand"); 

yield WaitForSeconds(delayTime);

//animation.Rewind("Stand");
animation.Play("Stand"); 

yield WaitForSeconds(delayTime);

//animation.Rewind("Sink");
animation.Play("Sink"); 

}

The invoking does not work... why oO?

What debug messages are being sent?

1 Answer

1

You can't invoke coroutines. You can rewrite that as a coroutine using a loop instead of using InvokeRepeating.

Not sure what to say without repeating myself. You can't invoke coroutines. If your function is a coroutine, you can't invoke it. As simple as that.