This tutorial by Vahé Karamian, the author of Building an RPG with Unity 2018 – Second Edition, will discuss the design of amazing RPG characters and take a look at some attributes and characteristics that you need to design and implement.
To have a meaningful and interesting RPG, the game should usually have more than one character class. One of the main characters is, of course, the Player Character (PC). You’ll first see the implementation of the PC, and then you’ll start defining and designing the other character classes—the Barbarian
class, the Villager
class, and the Orc
class.
The character models demonstrated here are from the Asset Store. You can either download the same characters or design your own.
The following assets will be used from the Asset Store for the character models:
It’s time to take a look at some of the attributes that the player will have in general.
The following is a list of attributes that will be part of the Base Character class:
The attributes you define for your characters depend on the character type, but there will be some similarities between all character attributes. That’s why it’s a good idea to implement these similarities in a base class that will be shared with all character classes.
To keep things simple, you will use only the five primary statistics for now, as follows:
The attributes listed are attributes that will be inherited by all character classes. Now put this into code. Create a new C# script and name it BaseCharacter.cs
. Here’s the class:
namespace com.noorcon.rpg2e
{
public class BaseCharacter
{
public string Name;
public string Description;
public float Strength;
public float Defense;
public float Dexterity;
public float Intelligence;
public float Health;
}
}
States are an important part of the character design. They will also drive the kind of actions and movement you will need to create for each state. For instance, your character will need to at least have the following states implemented:
Your character may have more states defined; this is something that you, as the designer of the game, will need to identify and eventually implement. Each one of the states identified will need to be implemented as an animation. The person creating the character models will usually also develop the animations for the character.
For instance, the Orc model has the following states/animations defined:
You may consider implementing the states entirely or partially. The theory and practice are the same either way.
You can also use RawMocap data to animate the models, since the models being used are Mecanim-ready, including Face Rigs.
The Mecanim Animation System was introduced with Unity 5. It is used for the following purposes:
Go ahead and download the asset from the Asset Store
right now. Do a search on Raw Mocap Data for Mecanim in the Asset Store
.
When creating your character models, it is a good idea to follow the proper bone structure set up for your characters. This will make controlling the states and the animations of your character easier, as well as reusing your Animation Controller on multiple characters. This is also true if you are going to use a character from the Asset Store.
You should now consider how your player character is going to look. There are several approaches that can be taken. An easy way would be to have a predefined hero where the player does not have many options or much choice when it comes to customization of the character. The other way would be to provide the player the ability to change and modify their character to an extent or fully. This all really depends on your budget!
You may use the Asset Store to download predefined characters that can be used as placeholders for your game while you create your own. You can even use some of the characters that are freely available through the Asset Store and modify them for your needs.
Once you have determined your character model, the next step is to configure it and customize it for your game. The character model used here can be visually modified to represent several unique characters.
Here is a set of character models that have been purchased from the Asset Store for the sake of this tutorial.
This model contains several body types—fat, regular, and skinny—which are set up by blendshapes on the body and cloth. It comes with 15 different body and accessory textures, one weapon texture, and two shield textures. This gives you a good range of unique character definitions and customization to enhance the range of different NPCs for the RPG.
Take a look at how to utilize them when doing character customization. See the following screenshot for an example of a barbarian:
The Villager models give you two groups of models: child and adult. In the adult group, you have the male, female, and monk types. There are 16 male, three monk, eight female, four child, and two equipment textures provided. For the female type, there are two types of texture: standard hair, used for loose hair, and hat, used with head accessories such as a hat.
There are two different sets of animations: one for the Adult
mesh type and one for the Child
mesh type. The child type has fewer states compared to the adult. See the following screenshot, depicting a male, female, and child villager:
The Orc model is a bit different in its structure. All body-type meshes are part of the main structure; there are three main models: Fat, Average, and Athletic. There might also be some legacy animations, which you must take care of when you start the configuration and programming of the Orc
class. See the following screenshot of an orc:
Drag and drop the Barbarian model from your project into the scene. You will need to study your character model carefully, and understand how it is built so that you can modify it during design time and during runtime, if necessary.
This particular model has several visual elements attached for weapons, clothing, and so on. Your model may have been configured differently; if so, you will need to create your own attachment points and instantiate the weapons and/or other character-related assets accordingly. See the following screenshot:
Select your character model and investigate the structure of the model. You will notice that there is a certain pattern and naming convention to the model hierarchy, as shown in the above screenshot. Some models might have animations attached. To check them, you will need to select the model from the Project
window and select the Animation
tab in the Inspector
window to get a list of the embedded animations for the model, as shown in the following screenshot:
In the Inspector
window, select the Animations
tab shown in the preceding screenshot, and notice the Clips
section for all the animations developed for your character model, as indicated in the following screenshot:
Notice that the animation clips have a start time and an end time. The actual character model is visually displayed at the bottom of the Inspector
window.
There might be times that you will need to Rig
your model to make it suitable for your game. This can be achieved by selecting your model source, and from the Inspector
window selecting the Rig
tab, as shown in the following screenshot:
In the Rig
tab, there are several options that you can apply to your model. Assuming that your character is of Humanoid
type, you will need to select the Humanoid Animation Type
if not already selected. The Avatar Definition
can also be either created from the model or assigned if you have an avatar defined. Finally, you can click on the Configure...
button to see the configuration of the rigged model. See the following screenshot:
Notice from the above screenshot that your model has a mapping defined for its skeleton. If your model is of the Humanoid
type, and if your model structure has been named properly, the system will automatically assign the correct bones and joints. If your naming is not per Unity specification, you can navigate your model structure and manually assign each point in the Body
, Head
, LeftHand
, and Right Hand
.
The Muscles
and Settings
tabs will enable you to define and restrict the movement of the joints for your model. These can be very useful and practical for creating more realistic movements for your characters. You can study these topics further on your own, as they would require an entirely new tutorial or two to cover them.
Creating characters entails more intuition than craft—you are the creator and you have the final say in how a character appears and behaves. As far as the craft goes, you can learn even more nuances about how to build immersive role playing games with Building an RPG with Unity 2018 – Second Edition. Taking an advanced approach, the book skips the basics of programming and puts more emphasis on the strategy, planning and implementation of the code to guide you through building an amazing gaming experience.
Please login to post your valuable comments.
Get the latest vLemonn news first