- Home /
Question by
andreas777 · Apr 26, 2015 at 08:35 PM ·
instantiaterandomspawnspawning
Object Spawning Randomly
So I have a code that works alright for spawning the object at specific spawn points but I want it to spawn randomly or even better have a lot of spawn points and spawn randomly in one of them. how can I do that?
//attach the enemy back to its original spwan point
transform.Find("Enemy").parent = SpawnPoint;
//reset the enemy to its spawn points position and rotation
SpawnPoint.Find("Enemy").position = SpawnPoint.Find("SpawnPosition").position;
SpawnPoint.Find("Enemy").rotation = SpawnPoint.Find("SpawnPosition").rotation;
//set a delay for the enemy, so it doesnt show immediately at the spawn point
SpawnPoint.GetComponent<Enemy>().Delay = (int)Random.value * 200 + 300;
Comment