Race between Health.ServerOnDie and GameOverHandler.ServerOnGameOver actions

There’s a race in the code as provided - it’s possible for the ServerOnGameOver event to occur after the ServerOnDie event, resulting in ResourceGenerator attempting to call enabled = false on an instance that was just destroyed and throwing an exception.

I’m not convinced that the subscription to GameOverHandler.ServerOnGameOver is required - the other buildings don’t need it, and the object’s Update won’t get called after it’s destroyed anyway.

1 Like

Hi There,

You make a good point, there should probably be a null check in there somewhere.

Probably, you would want this to exist for a situation where the resource generator is not destroyed when you die. Then it would need to be disabled.

Privacy & Terms