Reader small image

You're reading from  Game Development Projects with Unreal Engine

Product typeBook
Published inNov 2020
Reading LevelBeginner
PublisherPackt
ISBN-139781800209220
Edition1st Edition
Languages
Tools
Right arrow
Authors (4):
Hammad Fozi
Hammad Fozi
author image
Hammad Fozi

Hammad Fozi comes from a gaming background and has been extensively working on Unreal Engine since 2017. He has been part of some very successful AAA projects such as Virtua FanCave (and Metaverse), Unnamed AAA Sci-Fi DJ Experience, Heroes and Generals, and Creed: Rise to Glory VR. Hammad has worked with teams who have had experience working at Ubisoft, Warner Bros. Games, 2K Games, and more! He has successfully helped teams consisting of 10–30 people to scale to 150+ in size over his very short yet impressive career. Hammad currently works as a senior C++ game developer and has extensive experience in working with VR and augmented reality, PC/PS5/Xbox/Android/iOS/macOS game development, and Web3/Metaverse/NFT systems (within Unreal Engine).
Read more about Hammad Fozi

Gonçalo Marques
Gonçalo Marques
author image
Gonçalo Marques

Gonçalo Marques has been an active gamer since the age of 6. He has been using Unreal Engine since 2016 and has done freelance and consulting work using the engine. Gonçalo also released a free and open source plugin called UI Navigation, which has garnered an extremely positive reception with over 100,000 downloads and is still receiving frequent updates and fixes. Thanks to the development of this plugin, he became an Epic MegaGrant recipient. He is now working at Funcom ZPX, a game studio in Lisbon that has contributed to games such as Conan Exiles, Mutant Year Zero, and Moons of Madness. Gonçalo is currently working on a new Funcom game in the Dune universe.
Read more about Gonçalo Marques

David Pereira
David Pereira
author image
David Pereira

David Pereira started making games in 1998 when he learned how to use Clickteam's The Games Factory. He graduated in computer science from FCT-UNL, where he learned about C++, OpenGL, and DirectX, which allowed him to create more complex games. After working in IT consulting for a few years, he joined Miniclip in Portugal where he worked on popular mobile games such as 8 Ball Pool, Gravity Guy 1 and Gravity Guy 2, Extreme Skater, iStunt2, Hambo, and many others. Since then, he has been the lead developer for MPC in the John Lewis Christmas VR Experience, worked on an earlier version of Mortal Shell, and did volunteer work teaching people with Asperger's how to make games with Unreal Engine 4. Today, he's working on his own game, a soon-to-be-announced first-person action RPG.
Read more about David Pereira

Devin Sherry
Devin Sherry
author image
Devin Sherry

Devin Sherry is originally from Levittown, NY, located on Long Island. He studied the topics of Game Development and Game Design at the University of Advancing Technology where he had earned his Bachelor of Arts in Game Design in 2012. During his time in college, Devin worked as a game and level designer with a group of students called Autonomous Games on a real-time strategy styled, third-person shooter called The Afflicted using Unreal Engine 3/UDK where it was presented at GDC in 2013 at the GDC Play Showcase. Today, Devin works as an independent game developer located in Tempe, Arizona, where he works on personal and contracted projects. His achievements include the title Radial Impact, which can be found in the Community Contributions section of the Learn Tab of Unreal Engine 4's Launcher, and his work on his YouTube Channel, Devin Level Design, where he educates viewers on game development within Unreal Engine 3, UDK, and Unreal Engine 4.
Read more about Devin Sherry

View More author details
Right arrow

12. Animation Blending and Montages

Overview

By the end of this chapter, you will be able to use the Animation Montage tool to create a unique throwing animation using the Throw animation sequence you imported in Chapter 10, Creating a SuperSideScroller Game. With this montage, you will create and use Anim Slots that will allow you to blend animations in the Animation Blueprint for the player character. You will also get to know how to use blending nodes to effectively blend the movement and throwing animations of the character.

After finalizing the player character animation, you will create the required class and assets for the enemy AI and learn more about Materials and Material Instances, which will give this enemy a unique visual color so that it can be differentiated in-game. Finally, the enemy will be ready for Chapter 13, Enemy Artificial Intelligence, where you will begin to create the AI behavior logic.

Introduction

In the last chapter, you were able to bring the player character to life by implementing movement animations in a Blend Space and using that Blend Space in an Animation Blueprint to drive the animations based on the player's speed. You were then able to implement functionality in C++ based on player input to allow the character to sprint. Lastly, you took advantage of the animation state machine built-in Animation Blueprints to drive the character movement state and jumping states to allow fluid transitions between walking and jumping.

With the player character Animation Blueprint and state machine working, it's time to introduce Animation Montages and Anim Slots by implementing the character's Throw animation. In this chapter, you will learn more about animation blending, see how Unreal Engine handles the blending of multiple animations by creating an Animation Montage, and work with a new Anim Slot for the player's throwing animation. From there...

Animation Blending, Anim Slots, and Animation Montages

Animation blending is the process of transitioning between multiple animations on a skeletal mesh as seamlessly as possible. You are already familiar with the techniques of animation blending because you created a Blend Spaces asset for the player character in Chapter 11, Blend Spaces 1D, Key Bindings, and State Machines. In this Blend Space, the character smoothly blends between the Idle, Walking, and Running animations. You will now extend this knowledge by exploring and implementing new additive techniques to combine the movement animations of the character with a throwing animation. Through the use of an Anim Slot, you will send the throwing animation to a set of upper body bones, and its children's bones, to allow movement and throwing animations to apply at the same time without negatively impacting the other. But first, let's talk more about Animation Montages.

Animation Montages are a very powerful asset that...

Animation Montages

Have a look at the following figure:

Figure 12.3: The animation Preview window in the Animation Montage Persona editor

Underneath the Preview window, you have the main montage timeline, in addition to other sections; let's evaluate these sections from top to bottom:

  • Montage: The Montage section is a collection of animations that can add one or more animations to. You can also right-click on any point in the timeline to create a section. Sections allow you to compartmentalize the different parts of the montage into their own self-contained section that can be referenced and manipulated in the Sections area.
  • Sections: Sections, as mentioned before, allow you to set the order of how the individual animation sequences are played and whether a section should loop.

For the purposes of the throw montage, you do not need to use this feature since you will only be using one animation in this montage:

...

Anim Slot Manager

Anim Slot Manager is where you, as the name suggests, manage your Anim Slots. From this tab, you can create new Groups, which allow greater organization of your slots. For example, you can create a Group by left-clicking on the Add Group option and labeling it Face to articulate to others that the slots within this group affect the face of the character. By default, Unreal Engine provides you with a Group called DefaultGroup and an Anim Slot called DefaultSlot that is in that group.

Let's create a new Anim Slot.

Exercise 12.03: Adding a New Anim Slot

Now that you have a better understanding of Anim Slots and Anim Slot Manager, you can follow these steps to create a new Anim Slot, which you will call Upper Body. Once you have this new slot created, it can then be used and referenced in your Animation Blueprint to handle animation blending, which you will do in a later exercise.

Let's create the Anim Slot by doing the following:

    ...

Save Cached Pose

There are cases when working with complex animations and characters requires you to reference a pose that is outputted by a state machine in more than one place. If you hadn't noticed already, the output pose from your Movement state machine cannot be connected to more than one other node. This is where the Save Cached Pose node comes in handy; it allows you to cache, or store, a pose that can then be referenced in multiple places at once. You will need to use this to set up the new Anim Slot for the upper body animation.

Let's get started.

Exercise 12.04: Save Cached Pose of the Movement State Machine

To effectively blend the Throw animation, which uses the Upper Body Anim Slot you created in the previous exercise with the movement animations already in place for the player character, you need to be able to reference the Movement state machine in the Animation Blueprint. To do this, do the following to implement the Save Cached Pose node in the...

Layered blend per bone

The node that you will use to blend animations here is Layered blend per bone. This node masks out a set of bones on the character skeleton for an animation to ignore those bones.

In the case of our player character and the Throw animation, you will mask out the lower body so that only the upper body animates. The goal is to be able to perform the throw and movement animations at the same time and have these animations blend together; otherwise, when you perform the throw, the movement animations would completely break.

Exercise 12.05: Blending Animation with the Upper Body Anim Slot

The Layered blend per bone function allows us to blend the Throw animation with the movement animations you implemented in the previous chapter, and give you control over how much influence the Throw animation will have on the player character skeleton.

In this exercise, you will use the Layered blend per bone function to completely mask out the lower body of the character...

The Throw Animation

So far, you have put a lot of work into ensuring that the Throw animation blends correctly with the Movement animations that you set up in the Animation Blueprint in the previous chapter. The main reason behind this effort is to ensure the visual fidelity of the character when performing multiple animations at once. You will learn first-hand the visual consequences of incorrectly setting up animation blending in the exercises and activity ahead.

Getting back to the Throw animation, every modern video game implements animation blending in one form or another, so long as the art direction and the game mechanics require such a feature. An example of a modern game franchise that extraordinarily uses animations is the Uncharted series developed by Naughty Dog.

If you are unfamiliar with the franchise, you can watch the full gameplay of the latest installment here: https://www.youtube.com/watch?v=5evF_funE8A.

What the Uncharted series does very well is use thousands...

The Super Side Scroller Game Enemy

With the player character animating correctly when moving and performing the Throw animation, it is time to talk about the enemy type that the SuperSideScroller game will feature. We will have a simple type of enemy.

This enemy will have a basic back-and-forth movement pattern and will not support any attacks; only by colliding with the player character will it be able to inflict damage.

In the next exercise, you will set up the base enemy class in C++ for the first enemy type and configure the enemy's Blueprint and Animation Blueprint in preparation for Chapter 13, Enemy Artificial Intelligence, where you will implement the AI of this enemy. For the sake of efficiency and time, you will use the assets already provided by Unreal Engine 4 in the SideScroller template for the enemy. This means you will be using the skeleton, skeletal mesh, animations, and the Animation Blueprint of the default mannequin asset. Let's begin by creating...

Materials and Material Instances

Before moving on to the next exercise, we need to first briefly discuss what Materials and Material Instances are before you can work with these assets and apply them to the new enemy character. Although this book is more focused on the technical aspects of game development using Unreal Engine 4, it is still important that you know, on a surface level, what Materials and Material Instances are and how they are used in video games.

Note

For more information about Materials, please refer to the following Epic Games documentation: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/index.html.

A Material is a type of asset that can be applied to a mesh that will then control how the mesh looks in-game. The Material editor gives you control over many parts of how the end visual result will look, including control over parameters such as Textures, Emissive, and Specular, among others. The following image shows the default mannequin skeletal...

Summary

With the enemy set up with the C++ class, Blueprint, and Material, you are ready to move on to the next chapter, where you will create the AI for this enemy by taking advantage of systems such as Behavior Trees in Unreal Engine 4.

From the exercises and activities of this chapter, you learned how to create an Animation Montage that allows the playing of animations. You also learned how to set up an Anim Slot within this montage to categorize it for the player character's upper body.

Next, you learned how to cache the output pose of a state machine by using the Use Cached Pose node so that this pose can be referenced in multiple instances for more complex Animation Blueprints. Then, by learning about the Layered blend per bone function, you were able to blend the base movement pose with the additive layer of the Throw animation by using the Anim Slot.

Lastly, you put together the base of the enemy by creating the C++ class, Blueprint, and other assets so that they...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Game Development Projects with Unreal Engine
Published in: Nov 2020Publisher: PacktISBN-13: 9781800209220
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Authors (4)

author image
Hammad Fozi

Hammad Fozi comes from a gaming background and has been extensively working on Unreal Engine since 2017. He has been part of some very successful AAA projects such as Virtua FanCave (and Metaverse), Unnamed AAA Sci-Fi DJ Experience, Heroes and Generals, and Creed: Rise to Glory VR. Hammad has worked with teams who have had experience working at Ubisoft, Warner Bros. Games, 2K Games, and more! He has successfully helped teams consisting of 10–30 people to scale to 150+ in size over his very short yet impressive career. Hammad currently works as a senior C++ game developer and has extensive experience in working with VR and augmented reality, PC/PS5/Xbox/Android/iOS/macOS game development, and Web3/Metaverse/NFT systems (within Unreal Engine).
Read more about Hammad Fozi

author image
Gonçalo Marques

Gonçalo Marques has been an active gamer since the age of 6. He has been using Unreal Engine since 2016 and has done freelance and consulting work using the engine. Gonçalo also released a free and open source plugin called UI Navigation, which has garnered an extremely positive reception with over 100,000 downloads and is still receiving frequent updates and fixes. Thanks to the development of this plugin, he became an Epic MegaGrant recipient. He is now working at Funcom ZPX, a game studio in Lisbon that has contributed to games such as Conan Exiles, Mutant Year Zero, and Moons of Madness. Gonçalo is currently working on a new Funcom game in the Dune universe.
Read more about Gonçalo Marques

author image
David Pereira

David Pereira started making games in 1998 when he learned how to use Clickteam's The Games Factory. He graduated in computer science from FCT-UNL, where he learned about C++, OpenGL, and DirectX, which allowed him to create more complex games. After working in IT consulting for a few years, he joined Miniclip in Portugal where he worked on popular mobile games such as 8 Ball Pool, Gravity Guy 1 and Gravity Guy 2, Extreme Skater, iStunt2, Hambo, and many others. Since then, he has been the lead developer for MPC in the John Lewis Christmas VR Experience, worked on an earlier version of Mortal Shell, and did volunteer work teaching people with Asperger's how to make games with Unreal Engine 4. Today, he's working on his own game, a soon-to-be-announced first-person action RPG.
Read more about David Pereira

author image
Devin Sherry

Devin Sherry is originally from Levittown, NY, located on Long Island. He studied the topics of Game Development and Game Design at the University of Advancing Technology where he had earned his Bachelor of Arts in Game Design in 2012. During his time in college, Devin worked as a game and level designer with a group of students called Autonomous Games on a real-time strategy styled, third-person shooter called The Afflicted using Unreal Engine 3/UDK where it was presented at GDC in 2013 at the GDC Play Showcase. Today, Devin works as an independent game developer located in Tempe, Arizona, where he works on personal and contracted projects. His achievements include the title Radial Impact, which can be found in the Community Contributions section of the Learn Tab of Unreal Engine 4's Launcher, and his work on his YouTube Channel, Devin Level Design, where he educates viewers on game development within Unreal Engine 3, UDK, and Unreal Engine 4.
Read more about Devin Sherry