WaitForSeconds same time


I have a question :slight_smile:

I am using an IEnumerator for my PlayerContol script.

This IEnumarator is for moving the Player.

The Player can run too. And while running the Player changes scripts so that it looks like he is really running. When the Player presses shift I want the Player to run.

This is a part of the code:

    float speed = 1f;
        speed = 2.2f;
         speed = 0.7f;
         speed = 1f;
    yield return new WaitForSeconds(0.01f / speed);

If you press LeftShift the speed variable changes(I printed it).

But the Player speed is still the same.

I must use the speed on WaitForSeconds because of the ‘animation’.

Why doesn’t the Player run?

I fixed it.

Everything worked correctly in theory but c# can’t load the code so fast.
I changed the delay from 0.1f to 0.5f and changed the rest corresponding.