I am an aspiring Game Sound Designer, I have worked on film for some years and I want to make the jump.
So, I did the Space Shooter tutorial, but now I am trying to implement my own sound design to it, I already manage to add my own laser sounds using an array, so it plays variations of a laser shot to make it more dynamic and interesting.
Now I am trying to do the same with the asteroid’s explosions, but when I add the different sounds to the asteroid explosion prefab and I leave the Audio Source setting like on the tutorial, they are set to play on awake when the asteroid explosion Prefab is instantiated , obviously, all the sounds play same time.
So, the question is, how do I make an array to play random sounds when the asteroid explosion is instantiated? I created a script (C#) and added it to the asteroid explosion prefab, I also assigned the audio clips on the array in the inspector.
here it is:
using UnityEngine;
using System.Collections;
public class AsteroidBang : MonoBehaviour
{
public AudioClip[] asteroidbang;
private AudioSource bang;
void Awake()
{
bang = GetComponent<AudioSource> ();
}
void OnCollisionEnter(Collision other)
{
if (other = "Abang");
{
bang.clip = asteroidbang [Random.Range (0, 3)];
bang.Play ();
}
}
}
All your help is highly appreciated.