How to spawn an object in area2d?

Godot Version



Hello. I’m making a game on Godot and I have an enemy, and I need the enemy to spawn on another level in area2d, please tell me how to do this?

So basically you spawn a scene.

You need to load or preload it :

var enemy_preload = preload(“location_enemy.tscn”) # here you can drag an drop the location

var enemy = enemy_load.instantiate() # create an instance of the scene/node

add_child(enemy) # here you add the enemy to your scene or level