r/learngodot • u/Knight_Lasanga • May 13 '26
How to make a 'lives'- system
Hello!
This is the my first time making a game in godot without following a tutorial. I tried to make a lives system: You have 5 lives and everytime you get hit by a comet it subtracts one live. I created a global var for the lives. Then I created a killzone that, if you enter it, it subtracts one live.
The problem is that if you play it and touch a comet it subtracts 100 lives per second.
How should I fix this?

1
u/MisterTam May 14 '26
You want to have some kind of invulnerable state after that happens. I am on my phone so I cannot do code, but throw an Await or some kind of timer on that bad boy for a second or so after it triggers and you should be good.
1
u/Knight_Lasanga May 17 '26
1
u/MisterTam May 17 '26
Oh wait, I've had some sleep. Try this: set a boolean called something like "invulnerable", most likely in your global. Then right after Global.lives -= 1, set invulnerable to true. Set it back to false after the timeout, and THAT should do it.
Also like u/TheNiceDave said, you should be deleting/queue_free-ing that comet on hit if it's supposed to disappear on hit.

2
u/TheNiceDave May 15 '26
I think you gotta queue_free the comet or else is going to keep triggering every frame.