Version
Wwise Unreal Integration Documentation
|
This tutorial explains how to use Unreal Blueprints to play music from an integrated Wwise project. A Blueprint is suitable for music, which might play for the entire duration of the game across different levels.
To prepare for this tutorial:
Add a Music Segment that loops indefinitely. The following image shows the Container configuration:
uasset
is created.In this part of the tutorial, you will add sounds to the ThirdPersonExampleMap level. The level already contains various Actors such as Lights, Meshes, and a character.
Note: If you have multiple scenes, you can create a Persistent Level so that the music survives when a different map is loaded. See Managing Multiple Levels for more information. |
This tutorial uses the Blueprint of the playable character, which is available by default in the ThirdPersonCharacter content. To play, or "post", a Wwise Event, you have to do three things:
The following procedure explains this process in detail.
To post an event:
Drag a pin from the BeginPlay node, search for the Post Event Audiokinetic function and click it.
The Post Event function requires a reference to an Actor to place the Wwise Event.
Drag a pin from the Actor Object Reference, search for the Get a reference to self Variable and click it.
In the Post Event function, select the Play_Music Ak Event.
The Blueprint environment is ideal for controlling Actor behavior. However, to efficiently manage and position Actors in levels, you can expose some Blueprint controls in the Details panel and work primarily in the Level Editor instead. To do this, you can add an AkComponent to the Actor, which you can then use to offset the position of the sound from the Level Editor.
To use an AkComponent:
Drag the Ak component into the Blueprint, then drag a pin from the component, search for Post Ak Event and click it.
Connect BeginPlay to the Post Ak Event.
You can now retrieve the Wwise Event selected in the AkComponent.
Drag a pin from the AkEvent Object Reference, find and select a Get Ak Audio Event and connect it to the Ak component.
Drag the music Event from the Wwise Picker into the empty Ak Audio Event area.
You can now change the Event without opening the Blueprint, and you can offset the position of the sound relative to the Actor to which it is attached.
In most cases, you want interactive music in your game to adapt to gameplay conditions and provide variety. This tutorial demonstrates a common implementation strategy, which is to use States to control music.
Before you start, you must create a new music system in Wwise that consists of two distinct types of music: in this case, selection of calm music and a selection of intense music.
Create a Music Switch Container that can switch between "Repeat Calm" and "Repeat Intense" Music Playlists based on a “Music” State, as shown in the following image.
In the example, there are three States: Calm, Intense, and None. With this setup, you can set States from the game to change the music during runtime. You can also choose which State to set when the game starts.
A common approach, which this tutorial uses, is to set States when the player enters a certain area, defined by a Trigger. You create a Trigger Box and use a Blueprint system to set the State when the player crosses the boundaries of the box.
Ensure that you complete the steps in Using AkComponents before you proceed.
To control music with States:
In the Blueprint Editor, drag a SetState Audiokinetic function from BeginPlay.
Set the Initial State to Music-Calm.
The initial state is now set up.
Drag a Trigger Box into the Level.
Increase the size of the Trigger Box.
In the Details view, click the button with the three boxes (1), then New Subclass (2), type a Blueprint name (3), and then click Select (4), as shown in the following image.
The Blueprint is created, and contains an ActorBeginOverlap Event, which you can use to detect when something enters the Trigger Box.
From the ActorBeginOverlap, cast it to ThirdPersonCharacter and connect the Exec to a Set State function.
To ensure that you can use the Trigger Box for multiple states, you must create a Variable that is accessible outside the Blueprint.
Drag from the State Value and click Promote to variable.
There is now a variable under My Blueprint > Variables on the left.
Rename the variable to “MusicState” and click the eye icon.
The variable is now public (accessible outside the Blueprint).
Select the Trigger, then in the Details view select a State under Default > Music State.
In the level, walk into the new Trigger with the ThirdPersonCharacter and wait for the music to change.
You can now duplicate the trigger, reuse it somewhere else and set a different state without affecting the original trigger.
Note: If your Music Switch Container's Transition is set to Exit Cue, you might have to wait to hear the music change. |
Questions? Problems? Need more info? Contact us, and we can help!
Visit our Support pageRegister your project and we'll help you get started with no strings attached!
Get started with Wwise