Wwise RTPCs are useful for making changes to our Wwise sound objects by using game variables. In this tutorial we will set a RTPC by using Blueprints nodes provided by the Wwise integration plugin and by writing C++ code.
Controlling Wwise RTPCs by using Blueprints
We can use the Set RTPCValue node to control a Wwise RTPC in Blueprints:
In this example we are posting a Wwise Event and setting the RTPC value after a delay of three seconds:
If you want to set the RTPC value on a specific actor, make sure to connect an Actor to the Actor pin in the node, otherwise the RTPC will be applied on a global scope, i.e. on all Actors posting that Event. Make sure to reset the RTPC value to the original value at the start of the game or when quitting the game, as the RTPC will retain its value:
Naturally, we can also set the RTPC value on a AkComponent by using the Set RTPCValue node:
If you are setting the RTPC value every tick, make sure to set the Interpolation Time to 0 to avoid unnecessary processing:
Controlling Wwise RTPCs in UE4 by writing C++ code
In this example we are setting a RTPC named PitchParameter that changes the pitch value of a sound object in Wwise. We start by declaring a float variable called Pitch:
UPROPERTY(EditAnywhere, Category = "Wwise", meta = (ClampMin = "-12", ClampMax = "12"))
float Pitch;
The variable will show up in the Details tab of our Actor thanks to the EditAnywhere specifier. ClampMin and ClampMax allow us to visually restrict the range of the variable value:
We can now call UAkGameplayStatics::SetRTPCValue
to set the RTPC to our Pitch variable:
UAkGameplayStatics::SetRTPCValue(FName("PitchParameter"), Pitch, 500, NULL);
Alternatively, call the SetRTPCValue
function of the audio device singleton:
FAkAudioDevice::Get()->SetRTPCValue(*FString("PitchParameter"), Pitch, 0, NULL);
Without specifying an Actor as the fourth optional parameter, the RTPC value will be set on global scope, make sure to pass an Actor if you want to affect only one Game Object.
If we are using an UAkComponent
to post an Event we can call its SetRTPC
function to set a RTPC:
AkComponent->SetRTPCValue(FString("PitchParameter"), Pitch, 0);