You can safely ignore non-Bold text.
Hello, Unity Forums.
I just started making Games with Unity3D a few days ago, and i have had huge amounts of fun, thanks to the forums and the documentation i was able to resolve all my problems, but now i have reached a point where i cant find a fitting answer, nor can i figure it out myself.
So, im working on an FPS/Sandbox game in 3D, for the sandbox part you can summon different prefabs, that i created beforehand.
I am using Unity3D non premium edition,
and i am scripting in C#
Thats the basics. The problem i ran into, was the Following:
-
I add some Tunes to my Radio Script, tunes Array
-
I summon my radio prefab, add a slight bit of velocity to it, all fine
But then, for some reason, there is a about 90% chance no tune will be played ( Unexpected behaviour!) Just to clarify this, All of the slots of my array are being used.
So, i hope the Problem is clear now, please tell me if i should do anything to improve my posts further, here is the script, i wrote.(C#)
using UnityEngine; //sorry, Indents decided to go rogue.
using System.Collections;
public class RadioPlayer:MonoBehaviour{
public AudioClip[] tune;
AudioSource radio;
IEnumerator Start()
{
if(tune.Length>0)
{
do
{
radio.clip=tune[Random.Range(0,tune.Length-1)];
yield return new WaitForSeconds(radio.clip.length);
radio.Play();
}
while(gameObject); //probably unnessecary, but someone told that me this was good.
}
}
}