Robot Character Example
Preface
This page will guide you through the creation of a robot character that is powered by Inworld! This can act as a good first test in creating custom Inworld characters using custom assets within Unreal Engine.
Requirements
This guide will assume that you have already created an Inworld Studio Workspace, and have setup both an Inworld Player, and an Inworld Scene.
To follow along, you will need to add this Content Pack to your project's Content
directory.
The provided assets were created in Unreal Engine 5.1, and may not work with newer versions.
Creating the Robot
Creating the Blueprint
Create a new Actor Blueprint by right-clicking within the Unreal Engine Content Browser and selecting Create Basic Asset
> Blueprint Class
From the resulting Pick Parent Class popup, select Actor
.
Name the resulting Blueprint asset BP_Robot.
Adding Robot Assets
Add a Skeletal Mesh by selecing + Add
> SkeletalMesh
.
Set the Skeletal Mesh Asset on this component to SK_Robot.
Adding Inworld Components
Add an AudioComponent by selecing + Add
> Audio
, and an InworldCharacterComponent by selecting + Add
> Inworld Character
.
Edit the AudioComponent's default values. Set the Parent Socket to head so that the audio will emit from the robot character's head.
Edit the InworldCharacterComponent's default values. Set the desired brain name for the Robot, and add an InworldCharacterPlaybackAudio so that the audio data is sent through the Audio Component that was created.
Adding Facial Animation
Add two PaperSpriteComponents by selecting + Add
> Paper Sprite
.
Edit these PaperSprite's default values. Name one Eyes, and the other Mouth. Set the Parent Socket of each component to head so that the sprite will follow the head as the character's body animates.
For the Eyes, set the Source Sprite to SRP_Robot_Eyes_Idle_01, and set the transform to Location: (1,8.5,0) Rotation: (0,270,0) Scale: (0.003,1,0.003)
.
For the Mouth, set the Source Sprite to SPR_Robot_Mouth_Idle_01, and set the transform to Location: (-5,8.5,0) Rotation: (0,270,0) Scale: (0.003,1,0.003)
.
Animating Emotion
Create two Variables for the BP_Robot of type Paper Sprite. Name one CurrentEyeEmotionSprite, and the other CurrentMouthEmotionSprite.
Create two Variables for the BP_Robot of type Map, with a key of EInworldCharacterEmotionalBehavior, and value of Paper Sprite. Name one EmotionsToEyeSprites, and the other EmotionsToMouthSprites**.
With these Blueprint Variables setup, it can be utilized in the BP_Robot's Event Graph. Simply bind an Event to the InworldCharacterComponent's OnEmotionalBehaviorChanged. Using the Emotional Behavior provided by the event, map the corresponding Paper Sprite from the maps, cache the values, and call SetSprite on the Eyes and Mouth components.
Animating Visemes
Create a Variable for the BP_Robot of type Array of Paper Sprite. Name this MouthVisemes.
With this Blueprint Variable setup, it can be utilized in the BP_Robot's Event Graph. Simply bind an Event to the InworldCharacterComponent's InworldCharacterPlaybackAudio's OnVisemeBlendsUpdated. Since these Visemes are for human lip movement, simply select a random entry in the MouthVisemes array or the CurrentMouthEmotionSprite if the 'STOP' blend is not 0.
Adding Body Animation
Create a new Animation Blueprint by right-clicking in the Unreal Engine Content Browser and selecting Create Advanced Asset
> Animation Blueprint
.
Name the resulting Blueprint asset ABP_Robot.
Create a Variable for the ABP_Robot of type EInworldEmotionalBehavior. Name this CachedEmotionalBehavior.
With this Animation Blueprint Variable setup, it can be utilized in the ABP_Robot's Event Graph. Simply cast the Owner to BP_Robot, and bind an Event to the Robot's InworldCharacterComponent's OnEmotionalBehaviorChanged to cache the result.
In the ABP_Robot's Animation Graph, create an Animation State Machine.
Pass the output of the state machine to the Output Pose.
Open the Animation State Machine, and create a graph to change between Neutral, Angry, Happy, and Sad.
Setup each state with its respective animation.
For brevity, only the Neutral state will be shown.
For the State to Intro/Outro transitions, simply check if the CachedEmotionalBehavior meets the requirements.
For brevity, only the Neutral to AngryIntro will be shown.
For the Intro/Outro transitions, simply check if there is remaining time on the relevant animation.
For brevity, only the AngryIntro to Angry will be shown.