Death in my game

Godot Version

4.2

Question

Im trying to add a death sequence but the timer i set up isnt working

(code)
image

Here are some options that may fix your issue:

  • Make sure your timer has, in fact, been started.
    • Is death() being called?
    • Is DeathTimer the same name as the one in the node tree?
    • Try printing out the timer’s time_left value in the _process function to verify.
  • Double-check that the DeathTimer’s signal is hooked up to your object (in Godot) containing the _on_death_timer_timout() method.

If the above did not help, please describe your setup in more detail and the approaches you’ve tried so far.

i tried printing how much time was left and it only displayed zeros in the console

Okay. I assume you’ve checked the other stuff I mentioned as well.

Does your dead-variable get set anywhere?
…and when are you calling death()?

yes, it gets called at the start and declared as false

when the players health reaches zero it gets set to true

Alright. Show that to me.

What about your death()-function?
When is that called?

okay i forgot to add the part that sets the boolean to true lol, but it wont count down now


Nice. One thing fixed - unknown issues to go.

Where is your death()-function located?

like i said it loads the timer it just doesnt count down for some reason

Sorry. I meant where is the call to your death()-function?

i circled it in this image

I know what your issue is, I’m just trying to make you find it.

Okay - and where is that, in words, in your code?

the function? (sorry for being kinda difficult btw)

No worries. We are all beginners somewhere.

Yes. Where is the function call to death() (the thing you circled) located in your code?
Is it inside a particular function?

i put it here

No. That’s your function declaration; the place where you define your function.

Where is the call to this death()-function?:

  ...
  player_damage()
  death()
  
  print(@DeathTimer.time_left)
  ...

wdym call?

Hmm. Okay. Bear with me.
I’m gonna give you a longer reply that contains some important information along with the cause of your problem.

Give me ~10 min.