Audio source added to root of character even though an audio source exists there already.

I have NPCs jumping in distant locations in my scene and they sound like they're right next to me. I narrowed it down to an audio source that is added at runtime with a custom rolloff (Screenshot attached). It's picking up the same audio mixer group of the audio source I have at the root of the character's game object already but the rolloff is the big issue here for me as I can hear the jumping and landing audio from the NPCs and I can't adjust the volume without affecting everything that runs through that audio mixer channel. Where can I adjust the code or adjust the settings that control this added audio source, especially the rolloff setting?
 

Attachments

  • UCC added audio source to root of character.png
    UCC added audio source to root of character.png
    69.5 KB · Views: 4
I already solved my own problem. :ROFLMAO: Although it would be useful to still know how to control what gets created at runtime.

The solution: the added audio source matched the audio source I already had except for the Rolloff settings. Both were Custom Rolloff but the runtime Audio Source had what I'm guessing is the default Custom Rolloff curve. I just changed my original Audio Source to Logarithmic and the runtime audio source matched that and it's an acceptable solution to my problem.
 
The surface system creates a new AudioSource on the impacted collider's gameobject (e.g. the floor gameobject), unless there's already an AudioSource attached to it. You can see where this happens in SurfaceEffect.PlayAudioClip, which calls AudioManager.PlayInternal, which will get or add the AudioSource component on the target gameobject.

Also a couple of related threads which might help:
 
The surface system creates a new AudioSource on the impacted collider's gameobject (e.g. the floor gameobject), unless there's already an AudioSource attached to it. You can see where this happens in SurfaceEffect.PlayAudioClip, which calls AudioManager.PlayInternal, which will get or add the AudioSource component on the target gameobject.

Also a couple of related threads which might help:
Thanks Andrew!
 
Top