Scripts Process Loop?

Godot Version

4.2.2

Question

Hello all,

I received this warning message from the editor today saying:

“Consider using a scripts process loop instead of relying on a timer for very low wait times.”

Well, I was playing around with the timer to find how fast I need it to reset a variable, so, it play the correct animation in a Animation Tree and it only seemed to work @ 0.01. About as low as I could go, so, how would I go about using a “scripts process loop” in this instance as I have never used one of these.

As always any help is greatly appreciated!
Regards.

It means to override the _process function. Your timer is less than a single frame time.

1 Like

Ohh, well then, I really don’t know what to do, unless, I actually stick the variable in the actual animation player, that could work!

I though I might need a command that went along these lines:

get_tree().process_frame;

Which I basically don’t have the foggiest how that works. I’ll try the animation loop. See, if I can cause more damage :upside_down_face:.

Thankyou for responding.

Yep, putting the variable in the animation tree seemed to work - yay!!!

I have solved five errors that have been the bane of my existence with my project today - it’s been a great day :grin:.

Thanks for the clarification :sunglasses:.

get_tree().process_frame is a signal, which is emitted every frame. Thus you can use it like this:

do_some_stuff() # is called instantly 
await get_tree().process_frame
reset_variable() # is called next frame

Right! I had no idea about that. That might’ve worked as well. In fact, I’ll try that out right now …

Yep, that worked too :sunglasses:.

Thankyou greatly for that information. Looks like I only needed that “one” frame to reset the variable.

Regards.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.