Hi
I am currently working on a Sidescroller. My Camera is moving slowly forward and the player is only able to move around in the camera Screen.
now i wanted to spawn some enemies. These should spawn if the camera reaches a certain position on the X Axis but i have absolutely no clue how to do that.
Could someone give me some advice ?
Wow…guy isn’t kidding. He is indeed an angry marine.
All right, checking the .x or some other axis variable is one way to go and you can do that. Personally, I would prefer to go with trigger events. Basically what you can do, is along the path that you have for your camera, you can set up boxes at each point you want to spawn an enemy (or enemies). Name each box, and in the inspector check the box on the collider component that says “on trigger”.
So basically, whenever your camera collides with these boxes it’ll be sent an onTriggerEnter message. So write a script for your camera with the function:
void onTriggerEnter() {}
Then you can check the name of the box inside that function with a switch or else if statements and spawn your enemies in there. Then it stops becoming a guessing game with axis coordinates, and starts to look like a time scale or something. I hope this will work for you.