How to Set Up Characters in Your RPG Battle System
Zenva
ACCESS the FULL COURSE here: https://academy.zenva.com/product/rpg-academy/?zva_src=youtube-rpg-academy
TRANSCRIPT
Hey guys, welcome back. In this lesson we're gonna start our character script file. What I'm gonna do first is get rid of these by deleting them. Don't worry, they are in our Spells folder as prefabs. So inside of our scripts folder I'm gonna create a new C Sharp script and I'm gonna call it Character. Now this is gonna be the base class that all of our characters, well not all of them, we have two different types. We have a party member and an enemy object. They're going in inherit the values and properties from Character, so this is gonna be the base class for those two types of characters. So we're gonna have Character, we're also gonna have Enemy. Then we'll have a PartyMember, and Enemy is gonna be what our enemies are built on top of, and PartyMember is gonna be what our players will build on top of.
Let's open up Character in Visual Studio, and we're gonna treat this similarly to how we treated out spells. What does a character need? Well first of all, a character's gonna need a character name, so a public string characterName. We're also gonna have to have some stats. We're gonna need our health value. We're gonna need our attack power, our defense power. How much mana points do we have? What kind of spells can we cast? That kind of thing, so wanna have a public int called health, and I also wanna know how much health we could possibly have, so the health is going to be the current health. I then want to have a public int that's going to be the maxHealth. So I'll have say 10 health out of 20 potential health. That allows us to heal up to that maximum health. Think of a health bar, it's gonna have on the left side, zero, on the right side the maximum health our character can have. Also wanna have a public int for the attackPower, so how strong is this character. Whether they're just doing a normal attack or they're casting a spell, that kind of thing.
Then a public int that's gonna be defensePower. How much damage can we reduce incoming damage by? We'll create a very simple formula to help us decide how much our defense affects incoming damage. I also wanna know how much mana my character has, so input an int for manaPoints. I then wanna have a simple list of the possible spells that my character can have, so each character is gonna have a different set of spells. Say if we have a dragon character they'll have fire breath. If we have a ranged character, they'll have the arrow rain spell we just created, that kind of thing, so I wanna make sure that we have a list of spells per character I'm gonna have a public list, and I'm gonna call it Spell.
Now if you recall from the Unity 101 course, a list is a generic collection o ... https://www.youtube.com/watch?v=KCw6_vhvjiQ
42003741 Bytes