r0128 r0128 - 8 days ago 5
C# Question

IEnumerator not working

for some reason the motionBlur

IEnumerator
is not being called... where is my mistake?

public void Dash(){
lastDashTime = Time.time + dashWaitDuration;

motionBlur ();

animator.SetFloat ("Speed", 0);

playerRigidBody.MovePosition (playerRigidBody.position + transform.forward * 1.75f);
}


IEnumerator motionBlur(){
print ("Hello");
camMotionBlur.jitter = 10;
camMotionBlur.enabled = true;

yield return new WaitForSeconds (2);

camMotionBlur.enabled = false;
camMotionBlur.jitter = 0.125f;
}

Answer

You need to use Start Coroutine then it should work.

StartCoroutine(motionBlur());