I have a player and when he hits certain enemys it makes different sounds
I added audio source and added 1 clip which was easy and it does play but I want different sounds on different enemys
and since theres only 1 slot in audio source in inspector??
how do I add more clips to audio source? so he can play on different collisions different sounds or is this strictly done in code only?
2d
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class fishdedd : MonoBehaviour {
public AudioClip pop1;
public AudioClip boing;
AudioSource audio;
Animator anim; //reference to the animator component
void Start()
{
audio = GetComponent<AudioSource>();
//GetComponent<Rigidbody2D>().velocity = new Vector2 (forwardSpeed, 0);
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "Player" || other.gameObject.tag == "Wall" )
{
// do something when we collide with "enemy1" OR "enemy2"
anim.Play("fishded");
anim.SetTrigger("Die");
GetComponent<AudioSource> ().Play ();
audio.PlayOneShot(pop1, 0.7F);
}
else if (other.gameObject.tag == "tr" || other.gameObject.tag == "tr" )
{
// do something else when we collide with "enemy3" OR "enemy4"
anim.Play("fishded");
anim.SetTrigger("Die");
GetComponent<AudioSource> ().Play ();
audio.PlayOneShot(boing, 0.7F);
}
}
}
so for each sound I would have to add another audio component?
– sid4