0 votes

I have a scene enemy.tscn and inside a Node2D I want to load the scene and add the scene as the child for Node2D. but the load(res_path) function returns a Resource, and the Node.add_child(node) mehtod need a node as it's argument. how to resolve this?

asked Jun 7, 2019 in Engine by Thakee Nathees (239 points)

1 Answer

+2 votes
Best answer

Use instance():

var enemy = load(enemy_path).instance()
add_child(enemy)
answered Jun 7, 2019 by Dlean Jeans (3,915 points)
selected Jun 7, 2019 by Thakee Nathees
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.