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

0 votes

So I'm following on from the Wwise Unity Viking Village tutorial and I'm trying something that's pretty similar to the reverb footsteps in part 6. What I'm trying to achieve is eliminating/toning down the large mode ambient script that plays the ambient wind when a player enters a particular building. I've made a game object that covers the building's interior and have an aux send that can apply low pass and EQ to the audio. I just can't seem to find a way to apply this aux send to the wind ambience when the player enters the building. 

I am able to apply reverb and other effects via the aux sends to the footsteps, I just can't seem to find a way to apply the effects to the wind ambience.

The wind ambience is set to use 'User-Defined Auxiliary Sends' in Wwise. 

In Unity the game object has a Wwise Environment script set to play the correct Aux Bus.

Any help would be greatly appreciated!

in General Discussion by Joel S. (100 points)

1 Answer

0 votes

Hi there!

There are many many ways to do this in Wwise, but I think the way I would do it in your situation would be to have a box collider set to "Is Trigger" that encompasses the volume of the interior, then in Wwise create a state group that contains two states: "Indoors" and "Outdoors". On the bus or containers that you are affecting when you walk into the room, you can go into the "States" tab in the editor view and add your new state group to that object, and you can affect all kinds of properties. 

Now on the trigger object in Unity you can add this script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AKTriggerState : MonoBehaviour {

    public AK.Wwise.State indoorState = null; // If you are using events instead of states you can change these to be 'AK.Wwise.Event'
    public AK.Wwise.State outoorState = null;
    public bool changeStateOnExit = true;
    public string playerTag = "Player"; // You can change this to be whatever tag you want in the inspector

    void OnTriggerEnter(Collider c)
    {
        if(c.tag == playerTag)
        {
            AkSoundEngine.SetState((uint)indoorState.groupID, (uint)indoorState.ID); // If you are using events, this would change to: AkSoundEngine.PostEvent((uint)indoorState.ID, gameObject);
        }
    }

    void OnTriggerExit(Collider c)
    {
        if(c.tag == playerTag)
        {
            AkSoundEngine.SetState((uint)outoorState.groupID, (uint)outoorState.ID);
        }
    }
}

 

OR you could always make two events in Wwise: one that plays the wind and sets the effects on the wind's bus or container, and one that stops the sound or bypasses the effects, then trigger those on enter and exit. If the wind is persistent whether you're indoors or outdoors I would do it with states the way I described above, if it was only playing while you are indoors, I would do it with events. Or you could even use events to trigger the states! Many ways to do cool things in Wwise. 

by Blake J. (880 points)
Hi Blake,

Thanks so much for the info! I'll get to work on the project and see if I can get get it to work with states using the method you stated above ASAP and let you know how I get on!

Thanks, much much appreciated :)
Hi Blake,

I have a few questions regarding this process if I may:

- When you say "Now on the trigger object in Unity you can add this script" would you be referring to the game object on the Player? Or something else?

- I need the wind ambience to be playing as soon as the player loads into the scene and thus have an event script on a large mode game object set to play the ambience from the offset. I also have the states set up and have the state script on the box collider that encompasses the volume of the interior of the building, and set to play the indoor state. Is this sounding correct?

- To my understanding from your script, I need to name the states in Wwise, 'indoorState' and 'outoorState.' Is this also correct?

Many thanks for the help thus far, just still working things out! :)
Hi Joel,

Good questions.

1- Sorry for the confusion, I was referring to the Gameobject that is holding the box collider in the shape of the room. So in that case, the answer to your second question is yep that's right!

3- You can name those states whatever you'd like in Wwise, those names are just variables for the script to reference. Just as long as you select the correct states in the Unity inspector it should work.

Also be sure to have a collider on your player's head that is tagged  as "Player" or whatever you are telling the script to look for in the inspector!

Happy to help, let me know if you have more questions!
Hi Blake,

Again thanks for the help so far. I'm very nearly there, apologies for my inexperience with this whole process.

If I may, I just wondered if you could explain what you would specifically do to get the whole effect up and working in response to where I've got to thus far:

- I have the indoor box collider object with the States script that references the correct states in wwise.
- I have the 'Ambient' soundbank script that encompasses the 'Wind' event that plays the wind ambience audio file attached to a game object and set to load on start.
- I have the Player's tag set to Player for the states script to correctly reference the player.
- Setting up 'Debug.Log("Trigger enter called"); I can see on the Unity console that the box collider is correctly identiying that the player has entered/exited the indoor zone.
- On the Wwise profiler capture log however the states don't seem to be triggering.

Questions:

- If the soundbank that has the event in it is loaded on start do I need to add an event script as well?

- So if I wanted to play the Wind ambience audio from start and then have it affected based on whether the player is in the box collider or not (can be just affected when player goes inside and then revert to original when outside), how would you go about this, based on what I have set up currently? Because it seems like I might be missing a step? I.e. just with the states script no audio seems to play.

I appreciate your thoughts, let me know if I'm overthinking this :), just doesn't appear to be working just yet!

Link to Unity screenshot:https://www.dropbox.com/s/9tarbc70d1c0w59/Indoors%20Object.jpg?dl=0
I got it working by the way! Here's a link to a quick demo vid:

https://vimeo.com/261363515
...