![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Sumerechny |
Hello.
How to do this?
weapon_resource = preload("res://scene/weapon/Sword.tscn")
weapon = weapon_resource.instance()
get_node("AttackDown/PathFollow2D").add_child(weapon)
get_node("AttackUp/PathFollow2D").add_child(weapon)
get_node("AttackLeft/PathFollow2D").add_child(weapon)
get_node("AttackRight/PathFollow2D").add_child(weapon)
This code gives me these errors:
Can’t add child ‘Sword’ to ‘PathFollow2D’, already has a parent ‘PathFollow2D’.
Type:Error
Description: Can’t add child ‘Sword’ to ‘PathFollow2D’, already has a parent ‘PathFollow2D’.
Time: 0:00:02:0202
C Error: Condition ’ p_child->data.parent ’ is true.
C Source: scene\main\node.cpp:1331
C Function: Node::add_child
It seems like only one child is added, but why is that? The paths are different, so why can’t I add the same scene to a different path?