Introduction

In this article we implement our base character class. Firstly we implement BaseStats class in order to store our character’s base stats and pull them from this class where it is necessary. Secondly, we implement an AnimInstance class in order to create the character’s animation blueprint. Final class to be implemented is the character class.

Base Stats

Let’s start with holding our base stats in a class. We will be gathering all the base values of variables from this class. For this article we don’t implement archer and warrior classes, but let’s describe them as well.

Making Animation Blueprint Base Class with C++

Before starting animation implementations I’d like to mention the skeletal mesh and animations. Firstly I modeled our mesh in blender and create 14 different animations for this mesh. Then I import all of the assets to the project.

Blend Space for Idle / Walk / Run Cycles

Blend space is a useful tool for interpolating between different animations. Here, I just use it for idle, walk, and run animations which are based on the character’s movement speed.

 

Create a class derived from UAnimInstance:

We are going to hold two variables: one for character speed which will be used in Idle/Walk/Run BlendSpace1D and the other one is to check if character is attacking or not. In the future time we are going to implement more variables in this class to control our animations.

 

Animation Blueprint and State Machine

Let’s create our animation blueprint derived from the base class we just created.


Call UpdateAnimationProperties() function we implemented in our URTSBR_Character_AnimInstance class in the animation blueprint.

We are getting the character movement speed from RTSBR_Character_AnimInstance class.

Character

After making everything ready, we can implement our character class with ease. This class will be the base class of every character type of the game and will hold the basic information. For now we are needed to implement its:

Variables:

  • Health
  • Armor
  • Magic Resistance
  • Attack Damage
  • Magic Damage
  • Attack Speed

Functions:

  • ApplyDamage which will be called from the attacker actor for making the character damaged
  • Die function which will have lots of functionality such as making animation instance play the dying animation, deleting the character from character pool of the player etc.

Implementing these variables and functions is enough for now, but we are going to implement more as we need.

Result

 

Next time I am going to discourse on character selection and commanding. Until then, take care 🙂