# No repeat random

**URL:** https://discussions.unity.com/t/no-repeat-random/647605
**Category:** Scripting
**Tags:** Scripting
**Created:** [December 1, 2016, 6:28pm UTC](https://discussions.unity.com/t/no-repeat-random/647605 "2016-12-01T18:28:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Duttget233](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/duttget233/32/214069_2.png) [@Duttget233](https://discussions.unity.com/u/Duttget233)
#### Post date: [December 1, 2016, 6:28pm UTC](https://discussions.unity.com/t/no-repeat-random/647605/1 "2016-12-01T18:28:39Z")

</div>

Hi guys i need u’re help i have this code.

using UnityEngine;  
using System.Collections;

public class Randomm : MonoBehaviour {

public GameObject[&nbsp;] Item;  
public Transform[&nbsp;] Spawn = new Transform[3];

void Start () {  
Negro ();

}  
void Update () {

}  
void Negro () {  
int IndiceObjetos = Random.Range (0, 5);  
int Indicepawnbs = Random.Range (0, 3);  
Instantiate (Item[Random.Range(0,5)], Spawn[Random.Range(0, 3)].position, Spawn[Random.Range(0, 3)].rotation);  
Instantiate (Item[IndiceObjetos], Spawn[Indicepawnbs].position, Spawn[Indicepawnbs].rotation);  
}

}

i have this to spawn 5 prefabs and i want to spawn 1 pref in 1 spaw point and the second in other spawn point sometime the 2 objects spawn in the same spawn point, how can i fix it? And how can i do to take only object 1 and in the second random exclude object 1 and the didn’t have 2 identical objects in the scene?  
Thx.

---

<div class="post-metadata">

### Author: ![Kurt-Dekker](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/kurt-dekker/32/101578_2.png) [@Kurt-Dekker](https://discussions.unity.com/u/Kurt-Dekker)
#### Post date: [December 1, 2016, 6:45pm UTC](https://discussions.unity.com/t/no-repeat-random/647605/2 "2016-12-01T18:45:59Z")

</div>

First of all, please review the third post in the forum for how to format your code for readability.

Second of all, the general solution for what you want is to make a list of spawn locations (like you have), shuffle them in place, then consume them one after the other, only using each one once until you use them all.

Then you can shuffle the list again and start at the beginning of the list if you need more.
