When the asteroid collides with player, it's should make a hit sound, but never does.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AsteroidController : MonoBehaviour
{
GameController gameController;
[SerializeField] AudioClip hitSound;
// Start is called before the first frame update
void Start()
{
gameController = FindObjectOfType<GameController>();
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Destroyer")
{
gameController.AddScore();
}
else if(collision.tag == "PlayerShip")
{
AudioSource.PlayClipAtPoint(hitSound, this.transform.position, PlayerPrefs.GetFloat("MasterVolume"));
gameController.GetDamage();
Destroy(this.gameObject);
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if(collision.tag == "Destroyer")
{
Destroy(this.gameObject);
}
}
}