RPG Character Design: Technical Blueprints 101
In this article we will take a look at how you can design and develop from a technical standpoint your character classes for an RPG game.
The Hero Class Technical Model
As general development, this is not too hard of a task. The problem here is that a lot of times, the end-product is not reusable, it's not flexible and it's not generic. Here is a typical problem, when someone is making a design of this nature - more inexperienced developers tend to develop three separate classes - a Warrior class, a Mage class and an Archer class. And that's it. Just these three classes. Don't get me wrong, this will work. However, it's problem prone. What's not good about this concept? Here is a list of some of the biggest problems:- You have to re-write basic stuff that all of these classes have in common.
- If you have to change a basic concept of the characters, you have to make the change in all of these classes.
- If a consistent bug pops up, you are going to have to implement fixes in all of the classes.
- Many other things that may trip you up.
Developing the Technical Design
We will start off from the ground. Here is how our hierarchy is going to look.
Character Interface
First off, we will create the character interface. For this article, let's simply name it ICharacter. Now let's start thinking. What do all of these characters have in common? Well, they can all attack, move, trigger actions and die. Of course, each of them will have its own interpretation of these traits later on. So, the interface will have these methods:- onMove()
- onAttack()
- onActionTrigger()
- onCharacterDeath()
Character Class
Now that we have the Interface up and ready, we should create a basic class that is going to implement it. For this article, we will call the class CharacterBase. So how will it work? When we implement the interface, we will craft out the most basic logic that is going to be initiated for all characters in this. Each method will contain just the very basic amount of logic.- onMove() - In this method we are going to handle the character's movement patterns. We will also trigger the movement animation.
- onAttack() - since each of the character classes has a specific attack type, the only thing we will do here is handle the animation trigger and also make sure (in terms of game design, this step may vary) that we have the needed setup for the attack to commence. Calculate the damage to the target as well.
- onActionTrigger() - this should basically just trigger an animation whenever we want to interact with something. However, the three character types may have a different way in interacting with objects.
- onCharacterDeath() - this will trigger the death animation, save statistics or whatever is needed to be saved in order for the game to go further with its logic.
Warrior Class
We have the basics down. So let's create the Warrior class. We will call it WarriorCharacter. It will extend CharacterBase and basically override all of its methods. This is how the methods should be customized to fit the WarriorCharacter class:- onMove() - Here we will need to add a specific move pattern to the character. Since we have a warrior, he needs to move in a slow yet stable fashion. We will slow down his movement speed. After we've handled that, we will call the basic logic from CharacterBase by using super.onMove(). When the time comes to analyze the movement pattern, we will have already changed it, so now it initiates what we want. It will also trigger the warrior animation for movemet.
- onAttack() - the method should firstly check the distance from the Warrior's transform position in regards to its target. If we are in range - that is up close and personal, we will call the CharacterBase onAttack() method logic by using super.onAttack() or whatever technique your programming language supports in order to do so.
- onActionTrigger() - Our warrior has to be able to interact with breakable objects and well ... break them. This we will do by setting up a trigger in this method that will allow a breaking action for that specific object. How you can actually do that is something that should be designed on the object base, not the character. So, initially we will call the basic logic from CharacterBase and then expand on that by allowing the warrior to break stuff.
- onCharacterDeath() - To build upon the death animation logic, when a Warrior dies, we would want to implement a specific death effect, like dropping your weapon. After we call the original logic, we can add that as well.
super.onAttack() or the method you actually want to call. Mage Class
Now to implement the mage logic. We will call this class MageCharacter. It will extend CharacterBase and things will work much like with the WarriorCharacter class. Here, the distance of your attack is going to be vastly different from that of the warrior and gradually, the damage is going to be different as well. We are also going to have a missile effect to the attack. Again, when you put extra logic in your methods, make sure you are calling the original ones from the CharacterBase as well. If you don't do that, their basic functionality will not be executed and then nothing useful will come out of this. So this is how our basic methods are going to look for the mage character:- onMove() - Here the character pattern should be pretty normal. The movement speed as well. In physical terms, the mage is a normal guy so he should move around like the average people. However, we can use magic here. Let's way we use some sort of a skill (again, as said above, we will not go in-depth on the skill thing) that makes our mage fly. In this method we need to check if this skill is on. If it is, we change the movement pattern, the speed and even the animations for the mage.
- onAttack() - As with the Warrior, after we've found our range, the mage should be able to fire. This range however should be bigger then the warrior's range. At that point we should trigger a missile effect. It can be implemented through additional logic in the mages class that is out of scope for this article.
- onActionTrigger() - The magge has to be able to interact with objects through magic. That's to say that we should be able to use skills or our attack even on some objects, like spellbooks for example.
- onCharacterDeath() - Here we should implement a time-span for our mage to be able to ressurect himself if he has such a skill at his disposal. Then we can trigger the standard logic.
Archer Class
And just like with the mage and warrior, we extend CharacterBase with a class called ArcherCharacter. By now you've pretty much got the idea of how this is going to go. For the archer we would need a very fast movement with movement patterns that allow a fast strife from side A to side B of the visible/playable field. We would also need to implement fast and rappid attacks for this class. Maybe even a multiple shots kind of thing, where we initiate two attacks for the time of one. We would also most certainly be able to implement logic that allows us to interact with objects, such as a bush, so we can hide in it. On death, we should be able to implement logic that allows our archer to strike one lasw blow to it's target, before he goes out for good.Interesting Points
In this article I simply want to make a point on how you can do your most basic character class design. If you are to actually make this into a best practice kind of thing, you should make the hierarchy a lot bigger, including separate classes for melee characters, characters that use magic, range characters. From there do the inheritance for specific character classes. Also, to be fair, in order for this to actually work good, you would need a bigger array of methods at your disposal. Methods to handle your character's statistics, usage of skills etc. You would also need to add some variables to handle the health, stamina and a character-specific resource, like mana for example. However, this is going to get the article too complicated. This article is aimed for developers that have just recently started using concepts like Inheritance, Polymorphism and so on and so forth. If you can get down to write just your basic technical design down, then you should pretty much be able to go to an upper level with no problems.Conclusion
The technical side of the character class design is not something hard to understand or implement. Just keep in mind, that the concepts of Object Oriented Programming and the reusability factor that stands behind these concepts can save you a lot of time, bugs and make your code really better in all terms.Article Update Log
4 May 2013: Initial release 7 May 2013: Additional article format 19 May 2013: Remaking the article. Addint additional information and a diagram.Related Tutorials
Balancing Game Development and Creative Direction in Indie Production
A practical look at how indie developers can balance creative direction with hands-on game development. This article co…
My Unreal Engine Development Process: From Core Idea to Playable Build
A practical overview of my Unreal Engine development process, covering how I move from a core game idea to a playable b…
Introducing LaneGraph: The Ultimate Road Network Solution for Unity
Discover the power of LaneGraph, a lightweight and flexible lane-based navigation system for Unity. LaneGraph makes it…
Retargeting Mixamo Characters with Root Motion In Unreal Engine 5.4.
I have always found Retargeting Mixamo Characters To have Root Motion is a serious lengthy Tast, Recently I stumbled up…
How To Make A SIMPLE Main Menu In Unity
In this tutorial for unity, i go over how to make a simple main menu for unity, it's an unlisted video because i do not…
Guide to Gameplay Balance
A perspective on competitive gameplay balance, from a background of "shooter" sandbox design.
Discussion
More from Ivan Spasov
Crafting a Platformer Game
In this article we will take a closer look on how to create the Game Design for a simple Platformer Game.
Documentation for Indie Studios: Why do you need it?
This article features the importance of writing down good documentation for the entire development process. This is app…
Crafting a 2D RPG
In this article we are going to go over a Game Design outline for a turn-based 2D RPG.
Discussion