0 votes

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

Path2d
 PathFollow2d
  Sprite

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

Area2d
  Sprite
  CollisionShape2d

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

Godot version v3.2.3
in Engine by (12 points)

Do you add enemy as a child of path

add_child(enemy)

Also check if the any you instance have a script

Please log in or register to answer this question.

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.