WaitFewSeconds isn't working!

Hi all, I wanted the game to wait for 3 seconds after our Player gameobject is destroyed, then execute the code to load the ending scene level.

This is what I did.
1st: Declare and initialize a boolean variable.

2nd: Change the value of variable when player gameobject is destroyed.

3rd: Check for the variable’s condition in Update() and use the StartCoroutine function.

However the game doesn’t even load the next scene or logs out the sentence:
“Player lost is true”.

I’m assuming the playerscript is attached to the players actual ship? You’re destroying the ship and everything to do with it so the code runs until the end but i don’t think it will ever end up back in the update method otherwise you’d end up with lots of objects that are updating and taking up runtime without being in the game.

A possible workaround is to add the player lost check and the bool(as a static) to the level manager script which doesn’t get destroyed.

Alright, will give it a try!

OMG it works like a charm! Thank you very much! <3

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms