Как разместить 3 игровых объекта в диапазоне случайных положений, чтобы ни один из объектов не находился в той же позиции, что и другие 2?Как мне этого добиться?
Пока ..
public GameObject[] sprites;
int[] Position = new int[3] { 0, 5, -5 };
int resultSprite1;
int resultSprite2;
int resultSprite3;
int y;
int z;
Vector3 pos;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.R))
{
resultSprite1 = Position[Random.Range(0, Position.Length)];
y = 0;
z = 0;
pos = new Vector3(resultSprite1, y, z);
sprites[0].transform.position = pos;
resultSprite2 = Position[Random.Range(0, Position.Length)];
y = 0;
z = 0;
pos = new Vector3(resultSprite2, y, z);
sprites[1].transform.position = pos;
resultSprite3 = Position[Random.Range(0, Position.Length)];
y = 0;
z = 0;
pos = new Vector3(resultSprite3, y, z);
sprites[2].transform.position = pos;
}
}
Как этого добиться, чтобы никакие два объекта не занимали одинаковые позиции.Все они должны быть независимы друг от друга.
Спасибо.