How to know if there is a node at some position

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

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)

:bust_in_silhouette: Reply From: Lopy

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”)

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?

abelgutierrez99 | 2020-12-25 16:37