![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Atef |
Hi
I’m trying to add this child to this node but nothing happens that way, what’s wrong?
extends Area2D
var SOUND = preload(“res://tscn/sound_effect.tscn”)
func _ready():
var v = SOUND.instance().get_child(2)
add_child(v)
sorry but why dont you instance the child directly?
Andrea | 2021-08-24 16:50
Do you mean something like this?
SOUND.instance().get_child(4).play()
Atef | 2021-08-24 17:47
no… i mean, if you need the child n.4 of the scene SOUND
, why did you created the scene SOUND only to get the child?
couldnt you create a scene CHILD_n_4
and instance that?
by the way, i think it does not work cause parent.add_child(child)
only works if child does not has a parent.
so you first need to remove the parent of the child, and then add the child to another parent
Andrea | 2021-08-24 17:58