Custom Playback Types
Create a custom character playback in C++ or in Blueprint by creating a class of type InworldCharacterPlayback.
C++ and Blueprint playbacks share the same events to handle inworld messages.
Events
BeginPlay
void BeginPlay()
Used for initialization.
EndPlay
void EndPlay()
Used for deinitialization.
Tick
void Tick(float DeltaTime)
Called every frame.
OnCharacterInteractionState
void OnCharacterInteractionState(bool bInteracting)
Called when the owning InworldCharacterComponent has begun interacting with an InworldPlayerComponent.
OnCharacterPlayerTalk
void OnCharacterPlayerTalk(const FCharacterMessagePlayerTalk& Message)
Called when the owning InworldCharacterComponent has been talked to by an InworldPlayerComponent.
OnCharacterEmotion
void OnCharacterEmotion(EInworldCharacterEmotionalBehavior Emotion, EInworldCharacterEmotionStrength Strength)
Called when the owning InworldCharacterComponent has changed emotion states.
OnCharacterUtterance
void OnCharacterUtterance(const FCharacterMessageUtterance& Message)
Called when the owning InworldCharacterComponent has uttered.
OnCharacterUtteranceInterrupt
void OnCharacterUtteranceInterrupt(const FCharacterMessageUtterance& Message)
Called when the owning InworldCharacterComponent has been interrupted during an utterance.
OnCharacterSilence
void OnCharacterSilence(const FCharacterMessageSilence& Message)
Called when the owning InworldCharacterComponent has been silenced.
OnCharacterSilenceInterrupt
void OnCharacterSilenceInterrupt(const FCharacterMessageSilence& Message)
Called when the owning InworldCharacterComponent has been interrupted during a silence.
OnCharacterTrigger
void OnCharacterTrigger(const FCharacterMessageTrigger& Message)
Called when the owning InworldCharacterComponent has custom trigger invoked.
OnCharacterInteractionEnd
void OnCharacterInteractionEnd(const FCharacterMessageInteractionEnd& Message)
Called when the owning InworldCharacterComponent has completed their current interaction.
Message Queue Control
For some playbacks, it may be desired to pause the InworldCharacter's message queue, and resume the queue once the playback has finished processing the message.
Multiple playbacks may lock the message queue at the same time. The InworldCharacter will resume message processing once all playbacks have released their lock.
void LockMessageQueue()
void UnlockMessageQueue()
Sample Custom Playback - TTS
A common request is for characters to use a custom TTS instead of the voice audio provided by Inworld. The following shows a Blueprint example of a custom playback to replace the provided InworldCharacterPlaybackAudio using Unreal Engine's TTS.
⚠️ To follow this example, the 'TextToSpeech' plugin by Epic must be enabled for the project under
Edit
>Plugins
.
Initialization
To use the Unreal TTS, there is some required initialization. On Begin Play, add a default channel to the Text to Speech Engine Subsystem.
⚠️ If used for multiple characters, this Channel Id should be unique. 'TTS' is hard-coded here for brevity.
Playing voice
When the owning InworldCharacterComponent has an utterance, it is desired to play audio. On Character Utterance, activate the 'TTS' channel and speak on it. To prevent the InworldCharacter's message queue from continuing until the speech is finished, use 'Lock Message Queue'.
Handling Intterupts
When the owning InworldCharacterComponent is interrupted while uttering, it is desired to stop the audio immediately. On Character utterance Interrupted, simply deactivate the 'TTS' channel.
Continuing the Queue
Since we put a hold on the processing of the InworldCharacter's message queue in OnCharacterUtterance, it is necessary to allow it to continue once the speech is over. On Tick, try to use 'Unlock Message Queue' if the 'TTS' channel isn't being spoken on.
⚠️ It's not recommended to utilize Tick. Prefer using callbacks for event completion. In this case, the Text to Speech Engine Subsystem doesn't have an event to bind to, so checking on Tick will be used for the example.