- Home /
multiple object in multiple spawn Point with out repeat
hi this is my script for multiple object in multiple spawn Point with out repeat but i need to change little bit . i need some of my token repeat 7 time but some of them in 1 time what can i do for this any body help me? my code is this
using UnityEngine; using System.Collections; using System.Collections.Generic;
public class randomToken : MonoBehaviour {
public Transform[] spawns; public GameObject[] Bone; public int amountThings = 7; public int i = 0;
public void Start() { Spawn(); }
public void Spawn() { List freeSpawnPoints = new List(spawns); List freeObj = new List(Bone);
for (i = 0; i < amountThings; i++)
{
if (freeSpawnPoints.Count <=0)
return; // Not enough spawn points
int indexObj = Random .Range (0,freeObj .Count); int index = Random.Range(0, freeSpawnPoints.Count); Transform pos = freeSpawnPoints[index]; GameObject Obje = freeObj [indexObj]; freeSpawnPoints.RemoveAt(index); // remove the spawnpoint from our temporary list Instantiate(Obje, pos.position, pos.rotation); } } }
Your answer
Follow this Question
Related Questions
How can I Instantiate an Object from a Randomly Selected Index in an Array of Game Objects? 1 Answer
How to randomly spawn three non repeating gameobjects from an array? 2 Answers
instantiate a random object from multiples via 'tag' 1 Answer
How to instantiate the first 8 gameobjects in an array (UnityScript)? 1 Answer
Spawning Objects Using An Array. 1 Answer