Hi, all,
Can someone give me an idea of how to instantiate random prefabs using an array? I found a good script which does random audio with Random.Range.
var clipStorage : AudioClip[];
function OnCollisionEnter(collision:Collision){
if (collision.gameObject.tag == "wall")
if (collision.relativeVelocity.magnitude > 5)
{
audio.PlayOneShot(clipStorage[Random.Range(0,clipStorage.Length)]);
}
}
This is great for audio, but I am looking to instantiate a random GameObject using a similar clipStorage variable. Any ideas?
Thanks,
Greg
I had to jump on this cause i’m trying to build up my skill and thicken my library of scripts. And i think i got real close on my first try. You know like when your looking at your little compiler wheel and its taking a long time and your thinking man its about to give me tons of errors. But it liked it 
var projectile : Rigidbody[];
//@@@//=BLACK MANTIS=//@@@//
function Update() {
if(Input.GetButtonDown("Fire1")){
var projectile : Rigidbody = Instantiate(projectile[Random.Range(0,projectile.Length)], transform.position, transform.rotation);
}
}
Black Mantis,
Thanks a lot- that is badass! I thought I was on the right track with the above script, but your code works perfectly.
Thanks for coming to the rescue!
Best,
G