Ok To Use Signals in _physics_process() Function ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By scrubswithnosleeves

Hey All,

Quick question. I have only been using signals as one time emits or at least one call=one emit. is it ok to use them in the _physics_process/_process function? IE emit them every frame? (performance issues/bugs?)

My specific implementation is to communicate a player’s stamina to the HUD as it regens. is there anything wrong with using signals or should I just use a get_parent().get_node() chain?

:bust_in_silhouette: Reply From: njamster

That ultimately depends on your definition of “okay”, but generally speaking: yes. Choosing between calling a method and emitting (and connecting) to a signal shouldn’t matter much in terms of performance. General rule of thumb: do not try to solve problems that you have yet to encounter! I think the advice given here is usually sound: “call down, signal up”. It keeps scenes self-contained, which makes it easy to transfer them over to other projects or make changes in the tree structure.