In the previous chapter, we animated a subtle swaying animation cycle for our Alien Plant on the animation rig that only uses Forward Kinematics (FK). In this chapter, we will animate three animation cycles for our Robot Drone. Our robot has Inverse Kinematics (IK) controllers on its arms. This will give us a chance to get used to animating with IK controllers. You'll see for yourself how useful this kind of controller is for your animation workflow.
We will also learn how to save and load poses onto our Control Rig. Poses in animation are like a snapshot recording of all the transform values on all your controllers on your Control Rig. This is useful if you want your animations to start or end at exactly the same pose so they can seamlessly play from one to another.
In this chapter, we will cover the following:
In this chapter, we will only need to work in Unreal Engine 5. You will need the following to complete this chapter:
The files related to this chapter are placed at https://github.com/PacktPublishing/Unreal-Engine-5-Character-Creation-Animation-and-Cinematics/tree/main/Chapter18
In computer game animation, it is very common to have an idle cycle for a character. This is the kind of animation where the character does almost nothing. Typically, in a computer game, this is where the player is not pressing any buttons on the gamepad or keyboard and the character is just standing there. You'll notice during these times in games that the character normally has something like just a subtle breathing animation.
This is an idle cycle. It is an animation that repeats so the character still looks alive while doing nothing. If there was no animation the character would look like a statue and not alive. In some games, if you leave the character standing there long enough, it might scratch its head or look around. These animations are normally called fidget animations.
We will only need an idle cycle animation since the final sequence we will put together at the end of this book will be short, so there's no need for fidget animations.
However, before we start to animate our idle cycle, let's learn how to use the Poses tool in UE5.
In this section, we will create and save a pose for our Robot Drone as its default pose before we start animating it. This is useful since if we want to return the robot to the default pose without any transforms applied, we can do that by loading this pose.
Sometimes you start an animation and don't like the result. This way, you can reset all the controllers and start afresh. Let's get started:
We also provide the completed Robot Drone Control Rig in the final project file, which can be downloaded here with installation instructions: https://github.com/PacktPublishing/Unreal-Engine-5-Character-Creation-Animation-and-Cinematics/tree/main/FullFinalUE5Project.
The Robot Drone Control Rig is under: Content/RobotDroneControlRig.
The RobotBody will return to its original position, but the rest of the controllers will still be offset as shown in Figure 17.9.
Note
With the Poses tool, the Paste Pose option will only paste the pose to the selected controllers. When creating a pose, it will only save the pose of the controllers selected at the time. This is actually very useful since we might be happy with the body and left arm pose we created, but unhappy with the pose we created for the right arm.
In this case, we can just select the right arm controllers and select Paste Pose. This will return just the right arm controllers to the default pose without losing the work we did on the body and left arm. Additionally, when saving a pose, it creates a thumbnail screenshot for us as a visual reference to the pose. If you don't like the thumbnail, you can reposition the character on the screen to something you like and change it by clicking Capture Thumbnail as shown in Figure 17.8.
We have now learned how to save poses to the Poses library and then how to paste them back to our Control Rig. Next, we can start animating the idle cycle.
When animating an idle cycle, we want to make sure our main pose is interesting but neutral. Also, in character animation, generally, we want to avoid poses that are perfectly symmetrical, where the left and right sides are mirror images of each other. It just makes for very uninteresting visuals and makes it feel too mechanical.
Technically, our robot is mechanical, but we want to give it some personality, so it's better to give it a more interesting idle start pose. Typically, a lot of animations in computer games flow from the idle cycle base pose so this is also why we want something a bit more interesting here. At the same time, it is an idle pose, so it can't be too over the top.
Let's set our starting pose for our Robot Drone:
Now we have a nice pose that is not perfectly symmetrical, and the Robot Drone is starting to come to life. We can now save this pose to our pose library in the Poses tool.
Note
We now have our base idle pose saved, so if we load a fresh sequence and start a new animation with our Robot Drone Control Rig, this pose will be accessible to us if we want to start or end the new animation with this pose.
Note
At this point, you have three ways you can select the controller called RobotBody – in the main UE viewport itself, in the Sequencer TRACK window, or in the Anim Outliner window. It doesn't matter what method you use to select it. They all do the same thing.
The three boxes with the values are ordered: the X axis value in the first box on the left, then Y in the middle, and Z on the right.
So, looking at that, at frame 30 (on mine, since yours will probably be a little different), Location Z = 0.053817 and Rotation Y = 1.087937.
I just roughly moved and rotated the RobotBody controller, and that is fine if the resulting animation looks good when you play it back, but for the purpose of this exercise, let us change those values.
This will change the Location and Rotation value of the RobotBody controller keyframe on frame 0030. But to be safe, let us place a keyframe on all the RobotBody controller channels.
In the Setting keyframes for the Alien Plant Rig Control section in Chapter 16, Create Simple Swaying Animation Cycle in UE5 Sequencer, we set keyframes in the Sequencer TRACK window using the + keyframe. We can also set keyframes in the Anim Details window and they will appear as usual in our Sequencer timeline, just like doing it in the Sequencer TRACK window.
Now let us animate the arms of the robot.
If you look at frame 0000 and the ldle Cycle start pose, the right-hand controller is higher than the left-hand controller, so in the next step I'll be animating it down. I'll do the opposite and animate the left hand upwards, so they do the opposite in the animation cycle.
On frame 0000 in the ldle Cycle start pose, the claws on the right hand are more open and the claws on the left hand are more closed. Let's do the opposite during the animation cycle.
We now have set the pose and keyframes for the middle of the idle cycle animation. You can now press play on the Sequencer timeline to see the animation cycle play. Hopefully, the cycle looks okay at this point.
If not, you can edit the animation curves as we did in the Editing keyframes and animation curves section in Chapter 16, Creating a Simple Swaying Animation Cycle in UE5 Sequencer.
However, we can improve our new idle cycle a little bit by offsetting the arm animation keyframes to create what we call an overlap (things not moving at the same time in the animation).
Advanced Note
This is just a simple offset in the middle of the cycle to create some overlap with the arms, but we could do a complete offset by putting pre- and post-infinity on the curve channels for the arm controllers and offsetting all the arm controller keyframes. But that would mean a longer process and having to resave the start pose. For the purposes of this exercise, what we have done by just offsetting the keys in the middle of the cycle is good enough.
If you expand RobotLeftHand in the Sequencer TRACK window to see all the transform channels, you'll see that by moving the single keyframe on the collapsed view of the RobotLeftHand controller in the TRACK window, it moved all the transform channel keyframes at that frame.
It is like the keyframe on the un-extended view of the controllers in the TRACK window is the parent of the other keyframes on the transform channels that are on the same frame as shown in Figure 17.21.
Sometimes this just makes it easier to move keys around if we have lots of controllers and we don't want to extend them all to move the keys on all the channels. Also notice that when you extend the controller to show the channels, the parent keyframe stops displaying in the timeline. When you collapse (un-extend) the channels, it displays again.
If you're happy with your idle cycle after playing it back, you can export it as its own UE animation to be used later together with other animations.
The default export settings are good.
We have now finished our first animation idle cycle for our Robot Drone. Next, we will animate a movement cycle for the robot.
During the tutorial in this section, after completing the idle cycle in the previous section, I will teach you how to repurpose the idle cycle animation and adapt it to a movement cycle. This is a great way to reuse what we have already done and at the same time, you can learn a few ways to edit existing animations.
I call it a movement cycle, but in reality, it will be animated on the spot and the Robot Drone won't be moving forward for now, during the creation of this animation cycle. This movement cycle is a bit like an idle cycle but looks more like the character is flying forward while doing it.
We will play this movement cycle in our final sequence when our Robot Drone is moving around the scene and will then put actual forward movement in. So, during our final scene in this book, when the robot is hovering in the same spot, we will play the idle cycle, but when it starts moving, we will play the movement cycle.
We can start by duplicating the Idle Cycle LEVEL SEQUENCE so we can make it into something else:
During the movement cycle, we want to keep the motion of the Robot Drone's body and arms, but we want it a bit faster while moving forward, so let's make it faster by reducing the length of the cycle from 60 frames to 40.
When you now press play in Sequencer, you'll see it is still almost exactly like the idle cycle, only it plays about one-third faster.
Now let's adjust the animation further with an Additive layer of keyframes. Additive layers are simply a way in UE5 (and most good 3D animation software packages) to keep the existing underlying animation and add extra values on top of it without losing the original animation.
A practical example of this is what we will do next on our robot. We want to keep the body and arms bobbing up and down in the idle cycle, but we want everything to lean forward as it flies forward through the air.
Let's set up an additive layer for our Robot Drone Control Rig.
This will seem to duplicate the Robot Drone controllers, but when you hover with the mouse over the blue bar next to them in the Sequencer timeline window, it will display Additive as shown in Figure 17.30.
This is particularly important since we now want exact control over what channel we set the keyframes on. With Automatic Keyframe on, it will record changes on all the channels and sets of controllers as we make changes. This is not what we want. We want to only set keyframes on the new Additive controllers, so it needs to be off.
As an additional tip, when working with Additives in Sequencer, don't select the controllers in the viewport since it will select both the regular and additive controller and it might get confusing.
Now when you click play in Sequencer, the entire animation plays leaning forward. You applied your first Additive animation. To make the movement animation more distinctive, let's change the arms too.
Play the animation in Sequencer, and if you're happy with the result, it's time to export it.
We have now completed our second animation for our Robot Drone. Now let's do our third.
For the third animation, we will do an activation. In this activation, the robot turns on, then performs a greeting gesture, and then ends with the idle cycle pose. Here, you can let your creativity run wild and do what you want. At the end of the book, we will put together a final sequence in Sequencer where we will use all the assets we created while working through this book.
Our MetaHuman character will at some point push a button on its suit to activate the drone. The drone will activate, then acknowledge/greet them and then go to the idle cycle pose we saved before so it can blend seamlessly back into the idle cycle animation that we animated here.
How the Robot Drone activates and how it greets the character is up to you. The only thing we must do is end with the IdleBasePose pose (see Figure 17.13) that we can load from our pose library at the end frame of the animation.
Here, you will use everything you have learned so far about animating your Control Rig in Sequencer. I realize this might be a daunting assignment if you haven't done a full custom animation from scratch before. To help you, I'll briefly run you through the process I followed to complete this task.
I decided to do a salute after the Robot Drone activates. I hope it will serve as a good example of the basic process. The animated RobotAnim03_ActionAnimation LEVEL SEQUENCE will also be in the UE project at https://github.com/PacktPublishing/Unreal-Engine-5-Character-Creation-Animation-and-Cinematics/tree/main/FullFinalUE5Project accompanying this chapter so you can examine it if needed:
This will be helpful later if we want to export this part as an un-activated cycle to extend the playback for as long as we need in our final sequence.
If you have trouble remembering how to paste a pose from the Poses tool, have a look at Figure 17.8 in the Using the Poses tool in UE5 section of this chapter.
I hope you have great fun animating this last animation for the Robot Drone. It does take a bit of practice and experimenting to get animations to look good so don't worry if you found this difficult.
In this chapter, we learned how to use the animation tools in Sequencer and the Animation window better. We learned about saving specific poses in the Poses tool and pasting them back into our animations. We animated an idle cycle, then repurposed it to create a movement cycle, and finally, we animated a specific action with a few parts to it from scratch. We saw how useful and easy it is to animate with IK after the somewhat complicated process to set it up in the first place. We saved the animations we created for later use in the final scene we will construct.
In the next few chapters, we will explore how to use motion capture on our MetaHuman in UE5.
18.221.66.185