Leçon 6

Table des matières

Creating an Aux Environment

While you have learned how to add the AkEnvironment script onto a Trigger, you need to perform a few more operations if you want to create a new Aux Environment from scratch. Along with a Collider set to Is Trigger, you also need a Rigidbody component and AkGameObj script.

When Unity manages your game object positions, the AkGameObj will report these positions, related Game Syncs and Environment values to Wwise.

When adding an AkEvent or AkAmbient component, or simply posting a sound in Play mode, the AkGameObj component will be added automatically. However, you have to ensure that the AkGameObj is set to environment-aware in order to send the environment information, such as its aux bus assignment, to Wwise.

The Rigidbody is a component that allows the game to apply physical motion to an object.

This includes computation of gravity or velocity in a certain direction, and since every motion is calculated collectively in Unity's physics engine, Unity will also be aware of whether any of these objects intersect (Trigger) or collide (Collider) with each other. The Rigibody uses the Collider component, attached onto the same game object, to calculate intersections or collisions. You only need one Rigidbody attached to one of the two game objects.

[Note]

Good practice is to add the Rigidbody to the AkEnvironment game object to minimize the amount of Rigidbodies added in the Scene.

In the following steps, you will create a new Trigger in the Woodlands and, along with the AkEnvironment script, add the remaining Rigidbody and AkGameObj to it.

  1. In Unity, go to Audiokinetic > Certification > 301 > Lesson 6 and select Creating an Aux Environment.

  2. In the Unity menu, go to GameObject > 3D Object and select Cube.

    A Cube shape will be instantiated in the Hierarchy.

  3. Right-click the Cube game object, select Rename, then specify Woodlands.

  4. In the Hierarchy, drag the Woodlands game object into the AUX Environments game object.

    Let's start by fitting the shape of the Trigger to the Woodlands. The Woodlands region consists of a 'Road to the Woodlands' and a 'Road to the Pine Forest'. Preferably, each of these parts should have their own acoustics, so you only need to create the center of the Woodlands, covering the Waterfall, Evil Spit Plants, and so on.

  5. Use the Move tool, Rotate tool, and Scale tool to fit the Woodlands Trigger to the most central part of the Woodlands region.

    Let's now configure the game object by adding various scripts and deselecting those not needed. First off, let's make it invisible by disabling the Mesh Renderer, as the player should not be able to see the Trigger in gameplay.

  6. In the Inspector, disable the Mesh Renderer component.

    The Box Collider is currently not set to Trigger, meaning it will prevent other Colliders from entering it.

  7. In the Box Collider, enable Is Trigger.

    Then add the AkEnvironment script to the game object.

  8. Click Add Component, then search for AkEnvironment and select it.

    Notice that the AkEnvironment will, conveniently, warn you that you do not have a Rigidbody on the AkEnvironment and provide you with a button to add one.

    The most optimal setup for the Wwise Adventure Game would be to place the Rigidbody on the AkEnvironment because this would result in the least amount of Rigidbodies needed in the scene, thereby limiting physics calculations and CPU usage.

  9. In the AkEnvironment, click Add Rigidbody.

    The message will now disappear along with the Add Rigidbody button, and a Rigidbody will have been added below.

    In the same manner as you assigned the aux bus in the previous section, you should do so for this AkEnvironment component.

  10. In the Aux Name property, select the Woodlands aux bus and click OK.

    Lastly, all game objects used to post Events have already been given a AkGameObj component, except for the Player game object. As such, you need to add an AkGameObj to the Player, so all sounds posted by the player will be registered by the Aux Environment.

  11. In the Hierarchy, select the Player game object.

  12. In the Inspector, click Add Component, then search for AkGameObj and select it.

    You will now see the AkGameObj component on the Player game object, with the Environment Aware option enabled.

    That's it! You have now created a Trigger with a fully functional Aux Environment. Let's verify the implementation using the Profiler.

  13. In Wwise, go to Layouts and select Profiler.

  14. In the Advanced Profiler's Voices Graph Filter, expand Master-Mixer Hierarchy > Default Work Unit > Master Audio Bus > World > AUX > Region_Woodlands, then select the Woodlands aux bus and click OK.

  15. Remote Connect to the game, Play the scene, and run to the Woodlands.

    In Wwise, take a look in the Advanced Profiler. Notice that the Ambient_Waterfall and Ambient_Region_Woodlands Events are using the Woodlands aux bus, and all instantiated sounds inside the trigger, like Player_WeaponSwing or EvilSpitPlant_ShootBullet Event, will also be using the aux bus. You may exit Play mode.


Cette page a-t-elle été utile ?