Hi guys, I am new to leap motion development. I have been tried to make a SpawnRandom() on my coding to create some elements. I want to randomly pick up some random objects from an object such as a pillow. However, I don't know how to do it. Anyone can give me some suggestions?
public class randomSpawner : MonoBehaviour
{
public GameObject[] randomObjects;
public Transform spawnPos;
int randomInt;
void Update()
{
SpawnRandom();
}
void SpawnRandom()
{
randomInt = Random.Range(0, randomObjects.Length);
Instantiate(randomObjects[randomInt], spawnPos.position, spawnPos.rotation);
randomObjects[randomInt].SetActive(true);
}
}