Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Trying to Clone 1 of 5 GameObjects in a array

$
0
0
Hello there I am Trying to Randomly Clone 1 of 5 Gameobjects in a Array. with this code all it seems to do is clone all Gameobjects in the array and not just 1 GameObject. #pragma strict var RoomPos : Vector3; var itemPrefabs : GameObject[]; var testNO : int; var Obj : GameObject; function Start(){ RoomPos=this.transform.position; } function Update () { var RNO = Random.Range(1,6); testNO=RNO; if (RNO==1){ Obj=itemPrefabs[Random.Range(0, itemPrefabs.Length)]; } } function OnTriggerExit(other : Collider){ if(other.tag=="Player"){ SpawnRoom(); } } function SpawnRoom (){ //Instantiate(itemPrefabs[Random.Range(0,itemPrefabs.Length)],transform.position, Quaternion.identity); Instantiate(Obj); } Thanks for the the Help Past Present and future.

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>