- Home /
How to set up random spawnpoints?
Hello
I want to set up aroud 20 spawn points on a map. I want them to spawn randomly on these spawnpoints, then disapear again after half a minute.
Is this possible? And if, how do i do this...
Please note that I'm pretty new to programing so please include scripts :D
Answer by Meltdown · Jul 25, 2012 at 08:11 PM
Nobody is going to write scripts for you. Go to www.unity3dstudent.com and teach yourself.
You can do something like the following...
Create a spawnpoint prefab, that basically contains an empty gameobject, tag it as 'SpawnPoint'.
Create a SpawnManager script for your game, that when it starts, randomly places the spawnpoints around your map, using Random.Range()
In your GameManager script, get a list of all your spawn points using GameObject.FindGameObjectsWithTag("SpawnPoint")
With that list of spawn points, simply pick a random one, then use GameObject.Instantiate to instantiate your enemy prefab on the random spawn point position.
Your answer
Follow this Question
Related Questions
Room generator spawn 1 unique room 1 Answer
Quaternion.identity problem at random spawn 1 Answer
Spawn Script not working on Iphone. 1 Answer
Random Spawning 1 Answer
simplified spawn script? 1 Answer