Add an instance of the Explosion scene
Add a Timer node renamed to InvulnerabilityTimer
To include adjustments to the transparency of the sprite
The modulate property of a sprite sets its Alpha channel (transparency).
0.0 is invisible while 1.0 is fully visible
0.5 would be semi-transparent
Create the timeout function
Connect the signal in code or the Inspector
By default, Godot's RigidBody2D nodes do not track individual collision contacts.
In a physics engine, calculating and logging every single point of contact between moving objects requires extra CPU power. Because rigid bodies are primarily designed to handle physical collisions, bounces, and forces automatically on their own, Godot leaves detailed contact reporting turned off to keep your game running fast and smooth.
To use collision signals (like body_entered) or check contacts via code, you must explicitly enable Contact Monitor and set Max Contacts Reported (usually to 1 or higher) in the Inspector. This tells Godot: "Stop ignoring the touches for this object; start tracking them so I can run custom code when it hits something!"
Set Contact Monitoring to ON
Set Max Reported Contacts to 1
Write the body entered function for the player
We will write the explode function soon
Connect the signal in code or the Inspector
Write the explode function
Make the explosion node visible
Play the explosion animation
Connect the Player nodes dead signal
to the game over function
If you play test now and fly into rocks, after crashing three times you will be presented with the game over menu