#pragma strict
function Start () {
}
var enemy1 : GameObject ;
var prefab: GameObject ;
var prefab2 : GameObject ;
function Update ()
{
}
function OnTriggerEnter(Trigger : Collider)
{
if(Trigger.tag == "Player")
{
var instance : GameObject = Instantiate (enemy1,transform.position + Vector3(20,0,0),transform.rotation);
var instance2 : GameObject = Instantiate (prefab,Vector3(Random.Range(transform.position.x,transform.position.x+20),3,0),transform.rotation);
}
}
This the the code I am using to instantiate triggers.
My Doubt is that in line 20 i.e
var : instance2 : GameObject = Instantiate (prefab,Vector3(Random.Range(transform.position.x,transform.position.x+20),3,0),transform.rotation);
is there any way that the Instantiate function selects one of the two GameObjects i.e “prefab and prefab2” randomly instead of directly using “prefab”