Change a float value then change it again after seconds

I am currently trying to make it so when my player object hits a certain objects collider the players spped is set to 2 when it’s normally 10 and then 5 seconds later it’s reverted to normal. I am currently trying to use the code below:

IEnumerator SlowPowerUp () {

        speed = 1;
        yield return new WaitForSeconds (5.0f);
        speed = 10;

I then want this to run in the void OnTriggerEnter but I don’t know how to properly call it. Can anyone help me please?

NOTE: I’ve solved it :slight_smile:

1 Like

Hi Ellis, can you maybe post your solution? That way the next time someone has this problem they can learn from you!

Just seen this I just needed to take the f away from the 5.0 and then in VoidOntriggerEnter type StartCoroutine(SlowPowerUp())