I'm trying to play a sound effect when I pick up an item. I have the audio source component, and I have the sound clip assigned. I get no errors and everything seems to be working, but I still do not get sound when I pick up the item. My script:
public ParticleSystem pickupEffect;
public float speedPercentDrop = 50f; // 10% chance
public GameObject speedPowerUp;
public float healthPercentDrop = 70f; // 70% chance
public GameObject healthPowerUp;
private AudioSource puAudio;
public void Start()
{
}
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Instantiate(pickupEffect, transform.position, transform.rotation);
puAudio = GetComponent<AudioSource>();
puAudio.Play();
Pickup(other);
}
}
void Pickup(Collider player)
{
Debug.Log("Picked Up");
Destroy(gameObject);
}