Random Flashcards

1
Q

private float spawnPosX= 20;

private float spawnPosZ= 20;

A

if(Input.GetKeyDown(KeyCode.S))
{
Vector3 spawnPos = new Vector3 (Random.Range(-spawnPosX,spawnPosX),0, spawnPosZ);
Int animalIndex=Random.Range(0, animalPrefabs.Length);
Instantiate(animalPrefabs[animalIndex], spawnPos, animalPrefabs[animalIndex].transform.rotation);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly