Raycast how detect collision once?

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

when I call the method is_colliding it checks it all the time how I make a signal to only call it once? there are no signals for this node

:bust_in_silhouette: Reply From: Inces

is_colliding() just checks for collision. Whether it checks once or all the time depends on function You placed it. I assume You placed it in process(). Place it in the function, that will be executed in the moment You want to check this collision.

If You are looking for signal that indicate collision, then it is on_area or on_body entered. If Your node doesn’t have these signals, than You can attach area node to it as a child, and collision shape to it. This is how it is usually done.

Alternately You can modify code in process() to only check once and stop, by adding boolean variable. For example :

var once
func process() :
      if once == true:
            if is_colliding() == true:
                   once = false

and then refresh once into true when You want it to be checked again