0 votes

My Root node was set up like this

World
- Player
- object
- object2
- object3
- object4

My player has a certain area and when an object enters it prints out the position of the original object. I tried using getnode("/root/World/object").getposition()

But object is an instanced scene and I have several object2, object3, object4. Even if object2 enters the area of my player it still prints the position of the original object.

Godot version 3.2.3
in Engine by (12 points)

1 Answer

0 votes

When using the signal from your player's area, you get the body entering it. You can use it to print it's position. Assuming it's a 2D game:

_on_Area2D_body_entered(body):
    print(body.global_position)
by (617 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.