hi,
I’m trying to create a river sound.
if i attach the 3D sound on the river with add component, the sound is only eared if i’m near the center of my reaver.
How can it be eared near the entire object (and not only the center).
thanks
it would be better if you attach the sound to a object like a rock and the sound is like water splashing on the rock or you can add the sound to a empy object and copy it down the river
ouch! is there no way to attach an only sound ?
it’s hard to under stand you.“ouch! is there no way to attach an only sound ?” but i don’t thank there is
3D audio sources only originate from the x, y, z of the gameobject. Most people just duplicate the sources for large areas like rivers, waves hitting beach, etc.
I guess it would be possible to define a volume with collision boxes, that gives you an ambient sound from multiple audio sources. Performance and setting it up would be a pita I think.
I think you are interested in Audio Reverb Zones, which can be studied here: Unity - Manual: Reverb Zones
For something like a river, you’ll have to string them along the river itself.
Well i’ve some unity crash using to many 3D sounds even on mac and iPad.
I resolved the bug problem on ipad, if don’t use more than 8 concurrent 3D sounds in the scene.
That’s why i’m looking for some idea like spherecast to allow 3D audio sound around the whole object with sound decrease against distance of the object and not only the center.
But as i said in my other post: spherecast does’t seem to cast or collide anything behind the camera…
No idea?
well i started working with unity several days ago so i don’t really know if it works, but maybe create a gameobject that goes over the questioned area and then if player goes in it plays your sound, if he goes out again it turns it off again.
for the volume you can place several objects with diffrent volume, with that you would have full control over volume and distance
Here’s how I’ve solved this problem in the past:
First, associate some sort of shape with the sound source. For example, for a force field, the shape might be a rectangle. For a river, a spline - or, more simply, a series of line segments - would probably be a good choice.
Then you need a function to find the closest point on this shape to a point. Fortunately this is easy to do for segments, and finding the point on a set of segments can be reduced to choosing the closest of the points from each segment.
Finally, you create a script that tracks the transform of the object with which the audio listener is associated, and computes the closest point on the shape (sequence of segments in this case) to the position of that object. Each update, you move the object with which the audio source is associated to said closest point.
This has the effect that the sound will localize naturally as if it were originating from the object as a whole, rather than from a single location. And, only one audio source is needed.
As I mentioned, this is the method I’ve used in the past to solve this problem, and it worked very well.
thanks Jesse, your method seems fine, unfortunately i’m just a 3D artist, and i’ve just a few notions of programming.
Too bad your function is not implemented natively in Unity.
It would definitely require some programming and math knowledge to implement. But, it’s not quite as hard as it sounds, and I can guarantee it works (For what it’s worth…)
Don’t you want to sell it on the unity Asset store ? not too expensive please, I’ll be your first client
Eh, something like this is esoteric enough that it probably isn’t worth putting on the Asset store, IMO; I’d probably be more inclined just to put it on the Wiki.
Part of the problem with creating a general implementation though is that you have to decide what shapes will be supported for the ‘closest point’ test. If you support shapes A, B, and C, then eventually someone’s going to end up needing shape D. You could easily make the system extensible using inheritance, but at that point the system starts to become less trivial (both to use and to implement).
Honestly though, in the case you describe (localized sound for a river), there’s really not that much code involved. Anyway, if the feature is important to you and you decide you want to pursue it, I can probably try to walk you through it here on the forums.