Topic was automatically imported from the old Question2Answer platform.
Asked By
Hashtop
I need help with getting the node the raycast collided with. Before i used a string that contained the collision id of the node, but the id changes everytime i boot up the project. And the only thing i could do to make the results more reliable would be getting the node name. Is there anyway i can do this?
Use get_collider() which returns the first object that rayCast2D collides with be it an area2D or a body depending on your preferred presets. You can then use to_string() to get the name of the object, ensure to check if the result from get_collider() is not null. You can use this feature to ensures enemies do not see through walls.