My code is the same as Rick’s (I do that so that I can track errors with his help more easily), but the difference is that in this lecture, after his player is dead, the game over scene is loaded, however in my case my player dies and “GameScene” still continues with all the enemies shooting and flying around, even after 2 seconds meant for the “scene-switching” delay pass.
Here is the Level.cs code (just so that we’re sure I’m not missing something):
And here is Player.cs:
And here, is the error I’m getting:
When I double click the error, it takes me to Player.cs and highlights the Die() method. I tried rearranging the statements, e.g. putting the FindObject statement above Destroy(gameObject) statement, and certain things do change (If I put FindObjectOfType<Level>.LoadGameOver();
above the Destroy(gameObject)
statement, the player doesn’t even die, for example - if you believe this arrangement of statements is important tell me, but I do not think it matters, because if my code is the same as Rick’s I don’t think the problem is in the code at all, though I might be wrong).
In desperation I even updated the unity editor (thinking that this, perhaps, bug, is fixed in the latter versions) and I hardly ever do that. Help would be greatly appreciated! I don’t know what to do any more with this goddamn engine