func _process(delta):
if playerone.living == false:
$PlayerOneRespawn.start()
if playertwo.living == false:
$PlayerTwoRespawn.start()
if playerthree.living == false:
$PLayerThreeRespawn.start()
I want the code to check to see if one of the characters is gone, and if so, start timer, but the timers keep restarting before they finish, how do I just have it run through the code once?
I am still new to Godot, but the problem here is that you have it running through physics process, which is calling it every frame.
What you need is a function upon player death that activates once.
So you can use a signal or some sort of value to determine when a player dies, and upon death call the function to respawn.
You have it on _process() function. It will keep starting the timer every frame as long as the conditions are met. You can add more conditions to avoid this.
Have a on death signal on player.
Connect to that signal from level script.
Emit the signal from player script when he dies.
The connected function on level script plays once instead of every frame. Write all further logic there.
My newb two cents.
You could try checking the Timer’s is_stopped() method before starting the timer. I’m assuming that calling start() on a Timer that is already started will reset the countdown. Timer — Godot Engine (stable) documentation in English.
That said, @grzegorzgrzelczyk has given a better answer that will likely result in a cleaner architecture. I’m just providing an alternative if you want a quick and easy option. I think both have their value.