tom
New Member
Posts: 44
Posts: 44
|
Post by tom on Sept 6, 2016 9:08:46 GMT
I searched and clicked but did not find the solution. I would like to get the effect: I have a 3D scene. When player object approaches the object reproducing the sound at a distance of 10 meters, I hear the sound only then. The sound will be quiet and will continue to grow as player approach the sound object. The best solution would be to somehow enable and disable these objects with sounds, because I have them in 3D space quite a lot. Give any hint please
|
|
|
Post by DarkTonic Dev on Sept 6, 2016 16:03:34 GMT
If you don't want it playing all the time, add a trigger to the game object, then add EventSounds script and use events trigger enter and trigger exit. Set the tag or layer filter equal to something only your player has. Then play the sound and trigger enter would do "stop sound group if transform".
The sound group should be a 3d sound to get the volume behavior you're describing.
|
|
tom
New Member
Posts: 44
Posts: 44
|
Post by tom on Sept 6, 2016 21:26:27 GMT
Thanks! It works perfectly, and I met a new thing -> EventSound script :-)
|
|
|
Post by DarkTonic Dev on Sept 6, 2016 22:16:22 GMT
Yes, we use that script for 95% of all sound. It can do almost everything.
|
|
tom
New Member
Posts: 44
Posts: 44
|
Post by tom on Sept 9, 2016 15:02:30 GMT
But I have a problem that occurred during accurate positioning of the sound. My set up is:
- I have object with Event Sound Script. - In it I put triggers to play / stop playing sound. - Also I set in it: Sound Spaw Mode - Master Audio Location. - My sound has 3D setting, I set proper distance and curve.
Problem is that change the position of the sound on scene does not affect his playing. For example, it would be quieter when I move it far away from audio listener (which is my player). No matter where I move the sound, it is played in exactly the same way after that when I activate it by going into the trigger.
How can I change this?
|
|
|
Post by DarkTonic Dev on Sept 9, 2016 16:05:02 GMT
First, use sound spawn mode of caller location. Master audio location is for 2d sounds only.
2nd, check your spatial blend rule on the mixer. You may have changed it to "force to 2d".
If not, what's the spatial blend in the audio source set to at runtime for that Variation? 0 means 2d. 1 means 3d.
|
|
tom
New Member
Posts: 44
Posts: 44
|
Post by tom on Sept 9, 2016 18:48:02 GMT
1. Changed to Caller Location. 2. Everywhere I have set for the forced 3D. 3. And I have already set a number one. After changeg to Caller Location effect is that when a player enters the trigger, the sound starts right from the top left of graph, which is the maximum volume. I was moving the sound object in different places and always the same effect. This is my trigger object and below is sound object:
|
|
|
Post by DarkTonic Dev on Sept 9, 2016 19:30:37 GMT
All your screen shots show edit mode. You need to be double-checking that things aren't changed at runtime. Take some runtime screen shots please. Is the rolloff curve or spatial blend of the Audio Source changed at runtime?
Are you saying there is no change in volume at all when you get closer or further to the "wentylator1"?
The rolloff curve goes to 30 units. Is your trigger collider wide enough? What's its width? Roughly around 30?
|
|
tom
New Member
Posts: 44
Posts: 44
|
Post by tom on Sept 9, 2016 22:01:54 GMT
OK, I double checked and in runtime all settings are the same.
Slowly I begin to understand what's going on. I thought that the behavior of sound on the curve is influenced by the position of the sound object in relation to the audio listener. I mean that sound object which is played from the selected group after trigger activation. And it turns out that in this setup it is about the relationship: trigger - audio listener.
I realized this when you asked the question: Is your trigger collider wide enough? I used to think that the trigger object simply releases the action, and the location of the sound object determines its location in 3D space.
Hmmm, this is another news for me, I wonder how to arrange the sounds in the path of the player. The player has to go through the house -> there are different corridors and rooms from which different sounds are coming.
I wanted to use triggers because of reduced CPU usage. Correct me please, I may be wrong: If I put an object with Master Audio Play Sound and sound is 3D with specified range. Whether the sound is played all the time only increases its volume from zero when approaching to the audio listener or rather play starts when the value exceeds the zero on the curve?
|
|
|
Post by DarkTonic Dev on Sept 9, 2016 23:21:53 GMT
Since it's causing you confusion, I want you to first delete both Trigger Enter & Trigger Exit events from your Event Sounds and just use Start event to play the same sound. Does the sound behave correctly, i.e. sound louder as you get closer?
No, the trigger / collider has nothing to do with how loud the sound is heard. However if your trigger radius was less than your max distance, you wouldn't be able to hear the full range of falloff because the Audio Source wouldn't be playing all the time near the outer edges (or far worse, depending on how big the differences was).
You were originally correct. The rolloff curve is influenced by the sound object in relation to the Audio Listener.
Finally, the reason why it's good to use Trigger Enter / Exit is because if you have a lot of ambient sounds like this, you may run out of voices (Unity only will mute any that aren't the 32 with the highest priority). We have an auto-prioritization feature that assigns priority according to distance every X seconds that can help with this as well, but that takes a certain amount of performance as well.
-B
|
|
tom
New Member
Posts: 44
Posts: 44
|
Post by tom on Sept 10, 2016 10:49:26 GMT
This is a huge nut to crack, for me of course :-)
So, I deleted both Trigger Enter & Exit, instead I gave Start only. And I have the same effect. The sound is played according to the curve 3D, but it depends on position of the trigger object, not sound object.
If the distance from trigger object to the player is greater, then the sound is quieter. In contrast, if I do the same with sound object (which was started by the trigger) this does not change anything.
You said: "You were originally correct. The rolloff curve is influenced by the sound object in relation to the Audio Listener." And this is correct if I place the object with the sound in 3D space. This refer between sound object and player.
Unfortunately, above is not working if I play the sound from the group using the trigger. In this particular situation all refer to this relationship: the player - the trigger.
At the end you wrote an interesting thing about priorities. Maybe this is just my rescue! Rescue for me as an amateur, who wants to build something as a hobby and have at the same time joy and pride at the end: I was able, I made it! :-)
I have a small amount of graphics. These are the planes, and various cubes (walls, sound objects and the triggers). I do not have any textures (even one!), or any complex algorithms. Everything is very very simple - the player presses the arrow key and is moved to the next room, there listens to different sounds and has a choice of other simple tasks.
So maybe auto-prioritization is the best choice for me? :-)
|
|
|
Post by DarkTonic Dev on Sept 10, 2016 17:51:31 GMT
Auto-prioritization is good, but it's meant for just using the Start event (i.e. having too many things playing at once).
To clear one thing: if your trigger object stays in the same place and doesn't move, then the trigger object and the sound object will actually be in exactly the same position at runtime. You can see at runtime that the sound object moves to the position of the trigger object (caller).
If your trigger object moves around, then you'll want to instead use Sound Spawn Mode of "Attach to caller", which really just keeps following it.
|
|
tom
New Member
Posts: 44
Posts: 44
|
Post by tom on Sept 10, 2016 17:58:15 GMT
So if I do not use the Start Event than Auto-prioritization will not work? or else: Does Auto-prioritization work automatically if I use the Start Event?
|
|
|
Post by DarkTonic Dev on Sept 10, 2016 18:18:15 GMT
It will always work. There's no point using it if you will have less than 32 things playing though (meaning if you set up all the Trigger Enter / Exit events, you wouldn't need it). Either way would be fine.
|
|
tom
New Member
Posts: 44
Posts: 44
|
Post by tom on Sept 12, 2016 12:01:31 GMT
I understand that as a total amateur I can ask strange questions so thank you very much for your being patient.
I assume my scene is about 100 objects with sound arranged in different corridors and rooms. These objects will be quite a distance from each other, so that at the same time will be played up to 10.
There are also sounds activated by triggers. For example, I walk into a room and I hear where I am, the scene looks like and what I can do. These sounds will always be played in the appropriate order, one by one. Always one at a time.
In such a situation should I create a triggers for all these 100 objects arranged across the stage?
|
|