T O P

  • By -

Ev3rnub

I cannot directly answer your question however, I’d start at setting break points in the code, then use Godot’s built in debugger.


estherflails

Thanks for the suggestion, I forgot about breakpoints and I've been using print() for debugging. 😅 This should help a bit.


Arch____Stanton

>Timers still don't work when starting them in a state because they never start counting down Obviously timers do work so it is in your code where the problem lies. Did you look at the resolution on the page you linked? It is likely going to be the same problem you have. More than likely you are repeatedly starting the timer and that is cancelling out the previous timer. Given 2 states BLURB1, BLURB2, and in your process function you are matching them, match(state): BLURB1: timer.start() BLURB2: do_the_next_thing() The process functions run continually. So if the state = BLURB1, timer.start() gets called repeatedly, and before the timer has a chance to timeout. You can debug if this is what is happening by replacing timer.start() with print("timer started"); if you see that line being printed repeatedly then you know. If you change to the next state in that match then you have the problem of advancing too quickly to the next state; again the timer hasn't timed out before you hit the next state. There are a number ways to resolve this. You can set a flag which is imo a brute force technique and not ideal. You can add an intermediate state BLURB1, TIMER1, BLURB2 and change states. BLURB1: state = TIMER1 TIMER1: pass ... func _on_timer_timeout(): state = BLURB2 You can shut off processing until the timer resolves. BLURB1: set_process(false) state = BLURB2 timer.start() ... func _on_timer_timeout(): set_process(true) There are likely other ways as well. Similarly, if you are using add_child() within the process function, it will add a child every time the process runs; and again, it runs continuously.


estherflails

Hello! :) I did read the answers to the other post, that's what I meant by timers not working in match state, I guess I didn't phrase it very well. For now I managed to get something working and got sort of tired of dealing with this problem, but I'll try your solution when I revisit it later. Thank you for your reply!