To manage the player lives and spawning we will create a LivesManager.
Why don't we manage the lives in the SignalBus? SEPARATION OF CONERNS:
Keep the "Brains" (Logic) separate from the "Nerves" (Signals).
It shouts into the SignalBus: "I died! Here is my point value (100)."
ScoreManager (or GameManager) hears the shout.
It adds 100 to total_score.
It shouts back into the SignalBus: "The score is now 500."
HUD hears "Score is 500" and updates the text.
Add a new Node as a child
Rename it to LivesManager
Attach a new script to LivesManager
Add export variables for
number of lives
respawn delay
player scene
Remember to assign the Player scene in the Inspector
Create a function to connect
The current player to the died signal
Create a function to respawn the player
Instantiate a new player scene
Position it at the center
Create a function to decrease lives
Send the signal to the bus
If there are still more lives
Start with default number of lives
Create a variable for the current player
Connect the Player died signal
Add an Instance of the HUD
CONGRATULATIONS ON COMPLETING THE TUTORIAL