- Home /
How do I control where enemies spawn?
Hi there,
I have an empty game object that I am using as an enemy spawner/setup and I was wondering how I can spawn enemies in different places, without moving the game object? Sometimes I want more than one object spawned at a time and I don't want to fill the game with spawners that I have to keep track of...
I'm using the basic Instantiate(Enemy02v2, transform.position, transform.rotation);
command.
I found that using animations was one way but I'd prefer to control enemy movement through scripting ;-)
Any help would be greatly appreciated :)
What kind of setup do you have? Would a completely (or semi-) randomized spawning pattern work? Generally, I'd say going with a bunch of spawnpoints and only activating the ones you want would be the best course of action - would that just result in too many?
Hi Chris, thanks for the prompt response! Random is no good - it's an R-Type style game. I have worked it out though. Simpler than I thought:
Instantiate( Enemy01, transform.position + ( transform.right * 10), transform.rotation );
I'm glad you got it working! You might as well give a detailed response to yourself (below) and mark it as accepted so if someone else comes along with a similar problem, they can find your solution.
Answer by POLYGAMe · Jun 03, 2011 at 11:31 PM
For anyone else with this issue, I used the following:
Instantiate( Enemy01, transform.position + ( transform.right * 10), transform.rotation );
The "right" can be replaced with "up", or "forward" and you can move left, down and backwards by prefixing with -. Easier than I thought :)