Quantcast
Channel: Questions in topic: "random spawn"
Viewing all articles
Browse latest Browse all 125

Get value from random

$
0
0
Hi I have this code now. When another GameObject spawns i would want to delete/hide the previous one and i would like to know which GameObject did it spawned. I am still a noob but I am trying :D Thanks! { public GameObject[] arrows; public float interval = 5; // Use this for initialization void Start() { StartCoroutine(SpawnArrow()); } public IEnumerator SpawnArrow() { WaitForSeconds delay = new WaitForSeconds(interval); while (true) { GameObject prefab = arrows[UnityEngine.Random.Range(0, arrows.Length)]; GameObject clone = Instantiate(prefab, new Vector3(0.02F, 2.18F, -1), Quaternion.identity); yield return delay; } }`

Viewing all articles
Browse latest Browse all 125

Trending Articles



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