Skip to main content

The code after yield waitForSeconds doesnt run in a C# coroutine

This may may occurs when the Unity Playworks Plugin engine transpiles C# to javascript.

Consider the following C# code:

images-medium

This will translate to return true in JavaScript which will exit the function rather than continue it.

images-medium

Possible solution:

Example:

void Start()
{
Invoke("LaunchProjectile", 2.0f);
}

void LaunchProjectile()
{
Rigidbody instance = Instantiate(projectile);
instance.velocity = Random.insideUnitSphere * 5.0f;
}