Why does adding a 0 second delay cause my reference to resolve correctly but removing it causes it to fail

Im working on a tower defense game and the first goblin killed failed to update the score due to a bad reference. I added a 2 second delay before the reference since all subsequently killed goblins resolved the reference just fine and it worked so i started backing it down to see how low i could go and i got to 0 and it still worked however if i just remove the delay it doesnt work???

It’s probably because the Player Controller or the HUD was not created yet. A 0 second delay waits a single frame, which is enough for the Game Mode to spawn in the Player Controller, the HUD etc…

1 Like

That must be it. I wasn’t aware of the frame delay. The first enemy does spawn immediately. Ill delay the spawn and if it works without the delay ill know for sure.

Edit: That was it.

1 Like

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