I am creating a side scroller game where objects appear through level. My question is how do I make objects of enemies to appear at certain points in the game. For example, I have enemies from Set A and Set B. I want to have enemies set B to appears after all the enemies from set A.
Also, if I moving along the scene or level, I want certain enemies to appear as I move along the scene.
Is there anyway for me to have a function or code to have these object or enemies to appear throughout the scene?
You can write a script that instaniates all the enemies from Set A first, and then the enemies from B – for example, use a variable that keeps track of how many A enemies you’ve instantiated. When it’s above a threshold, instantiate B enemies instead.
Or you can keep track of where the player is using trigger colliders. When the player is in trigger area 1, instantiate A enemies. When the player is in trigger area 2, instantiate B enemies.
Inside trigger area 1, you can have sub-triggers. When the player enters each one of those, you can instantiate an enemy of the appropriate type.