0 votes

I have the same node that I actually need in two places on the tree. Is there a way to do this directly, or is there a way to solve this with code?

Looking forward to answers! A nice week!

in Engine by (80 points)

2 Answers

+1 vote
Best answer

If you mean the exact node instance you create, then no, the node is what it is, one can only exists in one place, because itself is an individual.
If you mean the node instances with the same type, for example, monster slime, and you want have this kind of monsters in different scenes, then yes. Save the scene and you simple do instancing through either the editor (The link like icon) directly or using add_child() in code.
Usually, when we want the same instance to be in different place (Exactly the same), that's what's called referencing, this may be done in code. You reference the node using variable like var NODE = get_node("/root/..../My_Node"). It can exists in different scripts, but not in different scenes. (Like a person can't exists at two different places at the same time, but the person's properties and infos can exist on different devices. When you send him 1$, you can send to his ACCOUNT1, ACCOUNT2....)

by (813 points)
selected by

Thank you so much! Just what I was looking for.

+1 vote

The same node cannot be in two different places simultaneously. However, you can add two instances of a scene to the tree. I'm not sure what you mean by "directly" though. More direct than adding it to place A first and place B after that? No.

by (10,628 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 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.