execute custom function every frame

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

Hello. I need to call a function in case of an event, but it will be executed only during the event, how to fix it?

event is on_body_entered

:bust_in_silhouette: Reply From: jgodfrey

If I understand what you want (execute a function in every frame when the body_entered signal is triggered, and continue until the body_exited signal is triggered), something like this should work:

(untested and not actual code. More pseudo-code)

var inside = false

func _on_body_entered(...):
    var inside = true

func _on_body_exited(...):
    var inside = false

func _process(delta):
    if inside:

func custom_func():
    # do custom thing