0 votes

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

Godot version Godot 3.3
in Engine by (16 points)

sorry but why dont you instance the child directly?

Do you mean something like this?


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

1 Answer

+1 vote
var SOUND = preload("res://tscn/sound_effect.tscn")

func ready():
var s=SOUND.instance()
var v = s.get_child(n)
s.queue_free() #
by (1,436 points)

Yes, thank you

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.