ontriggerenter question - controlling proper audio

Hello,

Lets say I have 2 cubes, both with rigidbodies, and 2 colliders. One collider on each cube is a trigger. All physics and ontriggerenter functions work great.

Now to the problem and question, I have a collision sound that plays oncollisionenter on each cube. This is so that if I have another object that strikes them, it will play the collision sound and everyone is happy. All this works perfectly. The problem though, what if the cubes strike each other? 2 sounds get played. I only want one sound to play. How to supress one sound so only one plays?

Thanks!

edit: of course, it’s ontriggerenter, not oncollisionenter. Made the changes.

Incredibly shameful and pathetic bump.

this is definitely an awkward situation.
could you tell us how did you play the audio clip

quick and dirty way is.
use AudioSource.PlayAtPoint() for playing clips
you can start with adding tag to the cubes. then separate the things you do when collision is detected.

if(other.tag == “cube”){
if(// there is no gameobject named “AudioSource”)
// play the sound
}