Version

menu_open
Wwise Unity Integration Documentation
Using AkEnvironment and AkEnvironmentPortal from the Inspector

In the Unity integration, you can apply AkEnvironment and AkEnvironmentPortal components to game objects. You can then associate these components with an Auxiliary Bus that has a Wwise Effect to simulate environmental effects on sounds. This topic describes how to use these components to simulate reverb effects, although you can use the same principles to apply other types of effect.

Tip:Another way to implement reverb is to use Spatial Audio. See the following topics for more information:

The examples in this topic are available in the Wwise Demo Scene, which you can download through the Audiokinetic Launcher (see Unity).

Prerequisites

Review the following prerequisites before you add environment and environment portal components:

Adding AkEnvironment Components

An AkEnvironment component embodies a simple environment zone. You can attach an AkEnvironment component to any type of collider.

There are three ways to add AkEnvironment components to your scene: from the Wwise Picker, through the Add Component menu, or with C# scripts.

To add an AkEnvironment component from the Wwise Picker:

  1. In the Wwise Picker, locate the Auxiliary Bus that has the reverb effect you want to use.
  2. In Unity, select an object in the scene. The object properties are displayed in the Inspector.
  3. Drag the Auxiliary bus from the Wwise Picker to the Inspector.

    An AkEnvironment component is added to the object, named after the Auxiliary bus:

To add an AkEnvironment component from the menu:

  1. Select an object in the scene. The object properties are displayed in the Inspector.
  2. At the bottom of the Inspector, click Add Component > Wwise > AkEnvironment. An AkEnvironment component is added to the object.
  3. To select a different Auxiliary Bus, click the Name to open the Auxiliary Bus window. Then, either select a bus and click OK or double-click the desired bus. Alternatively, you can drag an Auxiliary Bus from the Wwise Picker to the current Auxiliary Bus's name.

To add an AkEnvironment component with a C# script:

  • Call AkUnitySoundEngine.SetGameObjectAuxSendValues() at any time.

AkEnvironment Component Properties

Only four AkEnvironment components can be active at the same time in a single scene or for a single AkGameObj.

The AkEnvironment component has the following properties, accessible in the Inspector:

  • Priority: Defines the priority of an environment. The smallest number (0) has the highest priority.
    If a game object is inside more than four environments, only the four environments with the highest priorities are active (if the Default and Exclude Others flags are not set).
  • Default: A default environment is active only if it is the only environment that contains your game object.
    If the game object is inside more than one default environment, only the one with the highest priority is active.
  • Exclude Others: An environment with this flag cannot be overlapped by other environments.
    If the game object is inside an environment with the Exclude Others flag, all other environments are discarded.
    If the game object is inside more than one environment with the Exclude Others flag, only the one with the highest priority is active.
  • Name: The name of the associated Auxiliary Bus.

Adding AkEnvironmentPortal Components

You can use portals to combine the effects of two environments. The contribution of each of the two environments is determined by their distance from the game object. This is useful if a game object stands between two rooms or is in a tunnel that connects two environments.

To add an environment portal to your project:

  1. In the Unity menu bar, click GameObject > Wwise > Environment Portal. An environment portal object is added to the project hierarchy.

AkEnvironmentPortal Component Properties

You can place an environment portal between two environments to combine their effects while your game object is inside the portal. The portal must intersect with both environments. The contribution of each environment is determined by its distance from the game object. The closer the game object is to an environment, the more that environment contributes to the final effect.

The AkEnvironmentPortal component has the following properties, accessible in the Inspector:

  • Environment #1: The portal automatically detects all environments that intersect the portal. The environments on the negative side of the portal (opposite the direction of the selected axis) are available in this drop-down menu.
  • Environment #2: The environments on the positive side of the portal (same direction as the chosen axis) are available in this drop-down menu.
  • Axis: The axis determines the relative contribution of each environment. For example, if the Z axis is selected, then movement along the X doesn't change the relative contribution of either environment. Only movement on the Z axis affects their contributions.
    Note:The axis is in object space. Therefore, rotating the portal also rotates the axis.

Using Environments and Environment Portals

To use environments and environment portals, you need a game object with an AkGameObj component that is environment-aware. AkEnvironmentPortal objects automatically detect overlapping AkEnvironment objects. The overlapping environments appear in the two select-lists in the portal's inspector:

If too many environments overlap the portal, you can select which ones the portal combines. Only four AkEnvironments can be active at the same time for a game object. In the case of environment portals, the four AkEnvironments are selected as follows:

  • The environments connected to a portal and that have the highest priority are selected until four are selected or until there are no more environments connected to a portal.
  • If there are fewer than four connected environments, any unconnected environments in the scene are connected according to the following criteria:
    • Environments with the highest priority are selected until the limit of four is reached (if the Default and Exclude Others flags are not set).
    • A Default environment is selected only if no other environments are selected.
    • If your game object is inside an environment with the Exclude Others flag, then it is selected and all other environments are discarded.
See also

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise