Hi. I have two objects, a player and an enemy, and I have the following script attached to the enemy (as well as the sound effect).
void OnCollisionEnter2D(Collision2D coll){
if (coll.gameObject.tag == "Player"){
audio.Play();
}
else {
audio.Stop();
}
}
I want when the player hits the enemy, this sound effect to be played, but in my case the effect is played at the begining of the scene.
How can i fix this?