I am working on a top down shooter game, and have a enemy_spawner Node with packed scenes array, which is being filled with new enemies (scenes). Every enemy has a enemy script attached to it.
Enemy spawner script:
var e = enemy_array.pick_random().instantiate()
get_parent().add_child(e)
What I wanna do is, I want to instantiate few enemies of one type at once (to have some alien formations), but I dont know how to duplicate specific scene, or how to refer to the element inside the array of scenes. I have tried:
enemy_array[1] and change the position or even duplicate the Node, also I have tried by modifying the enemy script attached directly to the enemy node, but I receive instantly an error telling me that the Packed scene is null, since its not still spawned or so.
What I also have tried in a first place is much easier option: to make a root node of this enemy and then add few enemies as a sub Nodes like an array of duplicated enemies, but it was hard to fix the area2d and collision shape issues so I have canceled this idea and tought it would be much easier to modify the spawner script only.
Is there a way to change the behavior of each enemy inside the spawner script or I have to make a new enemy script specially for these type of enemies (maybe duplicate the node a few times)? Thanks!