Hello, I’m making my first 2D game with a Unity course, and I have the following issue.
When I start the game, everything works perfectly. My main player shoots a laser, and both prefabs are in the player script.
When the player loses all three lives, the main menu screen reappears, enemies and power-ups stop generating, and the gameOver variable that manages the start and end of the game returns to true.
The problem occurs when I start my game again. The player prefab, enemies, and power-ups are instantiated again, along with their corresponding coroutines. But when I press the spacebar, which is used to fire the laser, a crash occurs. I see the following message: "
You probably need to assign the _laserPrefab variable of the Player script in the inspector."
I don’t know why this is happening, as the variables are still correctly set in the Inspector, but it’s as if the ability to shoot is lost. Can someone help me resolve this? Thank you very much!