How to call method of a scene (script attached), which is a child node of another scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BradColbert

I had this structure in order a sprite to follow a created path


then i replaced the Sprite node with Enemy node which is a scene containing


In my root scene i created instance of path2d scene. everything works as enemy is following the path properly. At some point of the path i need to call some method (eg. shoot) of the Enemy scene but the engine says that this method doesnt exists.
turns out that none of the methods of Enemy.tscn are called (eg. _ready() … etc)

im getting the node in my path2d scene like that

onready var enemy = get_node("PathFollow2d/Enemy")

but cant call any methods on enemy as i said
Printing enemy object in _ready function of Path2d says its Area2d, so its not null

Also, if i drop the Enemy.tscn in the viewport (in my main scene), the init methods are called, but not sure why this doesnt work if Enemy scene is a child of that path2d/pathfollow2d

Do you add enemy as a child of path


Also check if the any you instance have a script

code | 2021-03-02 22:26