Answer the question
In order to leave comments, you need to log in
How to make objects not spawn too close (2d)?
public GameObject spawnObj;
public Vector3 spawnPos;
void Start()
{
StartCoroutine("spawn");
}
IEnumerator spawn()
{
for (int i = 0; i < 2; i++)
{
spawnPos.x = Random.Range(-4.3f, 4.4f);
spawnPos.y = Random.Range(-2.75f, 2.8f);
int wait = Random.Range(0, 1);
yield return new WaitForSeconds(wait);
Instantiate(spawnObj, spawnPos, Quaternion.identity);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question