Ok, I have found a solution… kind of. I recreated the prefab and attached the DataPickup script. I have changed the script to this:
public class DataPickup : MonoBehaviour
{
[SerializeField] AudioClip pickupSFX;
void OnTriggerEnter2D(Collider2D other) {
if (other.tag == "Player") {
AudioSource.PlayClipAtPoint(pickupSFX, transform.position, 1.0f);
Destroy(gameObject);
ScoreManager.instance.AddPoint();
}
}
}
The only problem is that the pickupSFX is very quiet, even though the volume in both the script & the AudioSource component is set to 1. Maybe we can figure out the solution to that. I assume it’s because of the transform.position but I don’t know the solution to that.