0 votes

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

Godot version 3.2
in Engine by (181 points)
edited by

1 Answer

0 votes

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 onarea or onbody 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:
                   dowhateveryouwantoncollision
                   once = false

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

by (1,110 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.