|
Post by chrisoshea on Jan 27, 2015 9:52:41 GMT
Hi
I'm creating a 2d game, my MasterAudio object is currently at zero in the scene, my player moves around the 2d world. My samples are mono.
Each item/character/scenery item in the world that emits a sound based on your proximity to it, i.e. range = 5, if you are at distance 5 it plays the sample at zero, as you approach the sound gets louder. This is script controlled based on distance between player and object, normalize to 0-1.0 and control volume.
How does PlaySound3D (PlaySound3DAtVector3AndForget) work? Is it based on the position to the MasterAudio object? If so I should make MasterAudio follow the player?
Is there a range, so it gets quieter further away, and can you set that range? Does this also do 2d panning?
Thanks Chris
|
|
|
Post by DarkTonic Dev on Jan 28, 2015 0:04:46 GMT
That your sound is mono doesn't really matter.
Only 3d sounds (checkbox set in Audio Clip) can automatically vary their volume based on distance. Panning is also only available for sounds set up as 3d. This is a Unity limitation.
PlaySound3DAtVector3 plays the sound at the position you specify. For 2D sounds there's no point to use that though.
Master Audio sounds will automatically follow the Transform "making" the sound if you use the MasterAudio.PlaySound3DFollowTransformAndForget method or use EventSounds script. Again, this won't matter unless you're using 3D sounds.
When using scripting, you can specify the volume to use if you know that based on distance.
|
|
futurecrayon
Guest
Posts: 0
|
Post by futurecrayon on Mar 25, 2015 18:43:49 GMT
Piggybacking on this topic for a related question.
I'm using to PlaySound3DFollowTransform to play sounds on various objects in my 2D game world. Is there a way to control the distance over which the sound volumes fall off? (E.g. "range = 5" in the original poster's example.)
|
|
futurecrayon
Guest
Posts: 0
|
Post by futurecrayon on Mar 25, 2015 19:03:33 GMT
Actually, I think I found it. I control the curve under the 3D Sound Settings of the AudioSource component for each Sound Group Variation. Is that the right way to be doing it?
|
|
|
Post by DarkTonic Dev on Mar 25, 2015 19:48:05 GMT
Correct future crayon. And it would be best to make or use an Audio Source template for that so you don't have to tweak every single Audio Source separately.
|
|