Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

how do you Create and Design Character class

Discussion in 'Scripting' started by LelandGMC, May 26, 2015.

  1. LelandGMC

    LelandGMC

    Joined:
    Apr 27, 2013
    Posts:
    15
    Hello,

    I'm making 2d side-scroller and i'm having an hard time figure out on how to create 4 player character class like an Mage, Warrior, Rogue and Ranger. I'm sorta thinking like:

    PlayerCharacter()

    Health
    Mana(Mage)
    Speed

    PlayerCharacter : Warrior()
    Block
    Damage Reduction
    Damage

    PlayerCharacter : Ranger()
    Rapid-Fire
    Rapid Dash of 3 seconds of invincibility
    Switch Stances(Melee & Ranged)

    PlayerCharacter : Rogue()
    Dodge
    Switch Stances(Melee & Ranged)
    Homing attack

    PlayerCharacter: Mage()
    Barrier
    Spell
    Switch speels

    If you were to design on building these player character Classes just four of them, what would be your approach on Design and Building them in the game
     
  2. El Maxo

    El Maxo

    Joined:
    May 23, 2013
    Posts:
    177
    I would firstly flesh it out a bit more. Imagine whoever to read this to be a idiot, descriptions on what these moves and classes do. I imagine you want your mage to be ranged and your warrior to be melee, but you haven't stated this. after that I would thing of a number of points, allocate a point value to there skills, so stronger and powerful skills costing more. with points leftover from this you can then allocate other stats like health, mana and speed. I hope this is helps.
     
  3. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I would make an interface class for a skill/spell system. This will let you have a list/array of skills that can all call the same function for using the skill, and then you can have skill code handled separately. Then based on what class a character is, limit what skills it can obtain. Have an interface called skill or spell and it need only have a void function called cast. Now you can make a bunch of classes that control projectiles or whatever, have them implement your spell interface, then when you use the skill, instantiate the spell and call GetComponent<spell>().cast();.

    If 'mana' is for mages you may want to move that into the mage definition instead :p Maybe define stamina for the ranged class, rage / adrenaline for the melee class, mana for the magic class.

    How simple is the game?
     
  4. LelandGMC

    LelandGMC

    Joined:
    Apr 27, 2013
    Posts:
    15
    Athough i've admit i've didn't think about the Stamina system for the warrior as well. The Ranger and Rogue will have Adrenaline and it builds up every second, even quicker by defeating enemies. The Warrior should have Stamina for it's powerful attacks and be able to block even when the gauge is depleted although less effective, it recharage for an short time. The Mana will be for the Mage and The inferace, though, i would like to player to get able to them quickly without them to struggle with it, something like slow down time for 5 sec to choose their spells carefully.

    That can tricky though, since it should be easy to pull it up and choose.