Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Spawn Random Prefab Continuously?

$
0
0
I wrote a piece of code but I would like it to spawn one out of two prefabs every 4 seconds. NO matter what I try and where I look I just can't do it. Help would be greatly appreciated. Thanks. (the second variable is redball) `using UnityEngine; using System.Collections; public class BallSpawner : MonoBehaviour { public GameObject purpleball; public float delayTime = 4f; IEnumerator Start() { var obj = Instantiate(purpleball, transform.position, transform.rotation) as GameObject; yield return new WaitForSeconds(delayTime); StartCoroutine(Start()); } }`

Viewing all articles
Browse latest Browse all 7934

Latest Images

Trending Articles

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