#coroutine issues

1 messages · Page 1 of 1 (latest)

sonic mesa
#

I'm using a coroutine to check if a player holds an input for a certain amount of time, this is called in _process() but the timer I use for this seems to "disappear" if I let go of the key in question and "reappear" then timeout when I hold it for the full duration. I made sure to await the coroutine when calling it.

#

actually it's called in a different function that's called in process but it just uses the returned bool to check if it should emit a signal or not.

shut moon
#

is this function being called every frame a key is held? if so the timer will keep restarting since youre calling start() so it will never time out.

sonic mesa
#

No it's being called the first frame the key is held

shut moon
#

Can you show where its being called.

sonic mesa
#

it's being called in here

#

and that is being called in here

#

Still not surefooted on a lot of this stuff so there's a large chance I did a big no-no here

shut moon
#

I recreated what you have and this "Works" Though probably doesnt work the way youre expecting.

If i hold the key sure that will print my statement after 2 seconds. but even doing the just_released bit even with a click it will still print

Because when it runs through this check function it just runs through for when I click the button and in that frame just_released is false so it still prints

I would try to create a system using signals instead of waiting on timer timeouts and start/restarting the timer when the input is held or released and do the action on the timers timeout with a signal.

#

ignore the state_machine stuff i just opened an old project to recreate it

sonic mesa
#

Ah ok