Book Image

Mastering Unreal Engine 4.X

By : Muhammad A.Moniem
Book Image

Mastering Unreal Engine 4.X

By: Muhammad A.Moniem

Overview of this book

Unreal Engine 4 has garnered a lot of attention in the gaming world because of its new and improved graphics and rendering engine, the physics simulator, particle generator, and more. This book is the ideal guide to help you leverage all these features to create state-of-the-art games that capture the eye of your audience. Inside we’ll explain advanced shaders and effects techniques and how you can implement them in your games. You’ll create custom lighting effects, use the physics simulator to add that extra edge to your games, and create customized game environments that look visually stunning using the rendering technique. You’ll find out how to use the new rendering engine efficiently, add amazing post-processing effects, and use data tables to create data-driven gameplay that is engaging and exciting. By the end of this book, you will be able to create professional games with stunning graphics using Unreal Engine 4!
Table of Contents (22 chapters)
Mastering Unreal Engine 4.X
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Retargeting animations


When I was choosing my characters, I picked the bear as my main game enemy. The choice came as a result of several factors. First, I liked the two attack animations that the bear has, it is very strong and has great key poses. Second and most importantly, the bear has no idle, walk, or run animations, and it's a good opportunity to check some of the Unreal tricks of duplicating animations from a skeleton to another different skeleton. This is called animation retargeting.

By default, when you import an animation for the first time, you will be asked to either use an already made skeleton asset from within the project, or to import the asset skeleton and build a skeleton asset out of it. For several animations of the same character, you will keep reusing the skeleton asset, but once you import a different character it'll force Unreal to create its own skeleton structure asset.

Now, as you might have noticed, each enemy of the Infinity Blade assets has its own skeleton assets, and our main focus here is to somehow get an idle animation alongside the running and/or walking animation for the bear. As you noticed, the bear has only two animations!

Now if you check what the closest animal is in body structure and skeleton hierarchy to the bear (and included in the assets), you will find the wolf asset. This asset has all that we need and more, it is very similar to the bear, and it has walking and idle animations, alongside other attached animations. The goal now is to retarget and close the walk and idle animations of the wolf and use them with the bear. After we finish that, we will retarget the walk animation once more, and change its speed factor in order to make it look like a running animation (a run is just a fast walk, huh?!), and that will save us the time of creating animations or assets from scratch. It will even save us more time if we want to send the bear asset back to Maya or 3dsMax to add some more animations for it.

The retargeting process is very simple; you can consider it as the following steps:

  1. Create an intermediate skeleton structure (called Set up Rig).

  2. Define the Source character skeleton (the wolf), based on the intermediate skeleton.

  3. Define the Target character skeleton (the bear), based on the intermediate skeleton.

  4. Retarget the required animation from the source into the target.

While we have a plan, let's get started in retargeting the animation. By opening the wolf skeleton asset, you will be inside the Persona editor. At the top there is a button called Retarget Manager. Hit it!

That will open the retargeting window for you; it is very simple, you need to create the skeleton by hitting Add New Retarget Source and then start assigning the wolf bones to the correct slots of the intermediate skeleton. You don't have to fill them all, you just need the animated bones to be assigned. Keep in mind, at any time, if you need to assign more bones that are not shown on the intermediate skeleton, you can press the Show Advanced button in order to display more bone options to assign. Nevertheless, from my experience with this wolf skeleton asset, those basic bones are enough.

After assigning the bones you should end up with something like the following:

Now, let's do the same thing with the bare bones. Open its Persona, and start assigning the bones to an intermediate skeleton. There are two things you might notice here: the wolf has one more bone within the legs, and it fits its real bone structure. In addition, the wolf has a tail, while the bear skeleton has no tail. That will not affect us too much, but make sure not to assign something wrongly. Feel free to ignore those extra bones from the wolf.

After assigning the bones, you should end up with something like the following:

Now it is time to do the final step, which is retargeting (cloning) the animations themselves from the source to the target. By accessing the animation assets of the wolf (under the animations folder within the wolf folder), you can select any of the animations (let's start with the idle animation); right-click and, from Retarget Anim Assets, choose Duplicate Anim Assets and Retarget. That's enough to take you to the final step of retargeting.

The Select Skeleton window will show up. This window will already have the retargeting source skeleton selected and display its character. It requires you to select the target (which is the bear), by selecting the bear skeleton (the one we have already assigned to the intermediate skeleton) and hitting Select; that will copy the animation right away for you, and set it to the animation for the bear.

Now it's time to rename the animation to something which makes more sense. The new animation will still have the name of the wolf, but it has a thumbnail of a bear character, and it is only playable over the bear skeleton; thus you probably need to rename it bear.

Do retarget all the animations you want, but don't forget to rename them and move them to the bear folder, just to keep things organized.

After you are done duplicating/retargeting all the animations you want, I would recommend you duplicate the walking animation again for the bear, but this time name it run. After you have done the duplication, double-click on the animation asset. That will run Persona again, but this time it will be activating the Animation tab, not the Skeleton tab like before.

From the left side, there is a panel called Anim Asset Details. Make sure to set the Rate Scale under the Animation tab to 2.0, which will change the speed of this animation asset. By having it run fast, it really looks like a real run. Now we have managed to get lots of animations working and running for the bear, without the need to do a single animation frame!