0 votes

Hello, I'm new to Godot,
I was wondering is there is a way to check is at some point there is a node at some position (node.translation == position). I can do this storing all nodes in an Array and make an if statement, but this might be inefficient. (I'm making a 3d game)

Godot version 3.2.3
in Engine by (249 points)

1 Answer

+1 vote

You would use Areas for that. They can tell you what is inside their bounds, but have two caveats :

  • They can only detect other collision based objects (other Areas, your player, etc)
  • They only update the information once a tic, during physics. You may want ot run your code under some _physics_process(), or use a yield(get_tree, "physics_frame")
by (2,684 points)

But what I want to check while some code is executed, for example: a random walk that create tiles and I want to avoid two tiles at the same point?

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 Frequently asked questions and 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 [email protected] with your username.