Community Q&A

Where Wwise users help each other out!

Audiokinetic's Community Q&A is the forum where Wwise users ask and answer questions within the Wwise community. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

Switch sounds depending on distance

0 votes
Hello!

I've searched around a lot but I can't find anyone talking about this topic.

I'm building character interaction in Unity where I'd like characters to talk to you if you're close and yell if you're far away. Ie, I would like to trigger different voice tracks depending on distance. I don't want to use a blend container, since I don't want to change sound as you move closer. I just want to start the right sound depending on the distance to the target at that moment.

I'm looking for a best practice for this. Is there any nice way to do this in Wwise, or should I code this entirely in Unity and just use Events?
asked Feb 1 in General Discussion by Petter S. (100 points)

1 Answer

0 votes

Hey Petter, 

There's many ways to do this, but this is definitely possible both using Events or by coding.
If you don't need the granularity between far and close, you can make a Switch, and then set the Switch from either...

- An Event that sets the Switch.
Make a Switch with two switches (far and close), assign the Switch in a Switch Container and then right-click the Switch Container > New Event > Set Switch. 

- Or from code like this: 
public Ak.Wwise.Switch Switch_Far;
public Ak.Wwise.Switch Switch_Close;
... and then from a function, use the .SetValue(). Just make sure to set the switch before you post the sound itself, and also on the same game object. 

There's also more on Switches in the Wwise-301 course
If you want to learn more about the differences between States, Switches and Game Parameters, try watching this One Minute Wwise video.

Let us know if this helps!

answered Feb 3 by Mads Maretty S. (Audiokinetic) (3,420 points)
Another note. You could also set an RTPC based on the distance, and then connect that RTPC to a switch. This would allow you to control when something is "far" or "close" inside Wwise, instead of inside Unity.
...