What is the BEST Way to do Character Classes

So In my game I am thinking of allowing the player to change different classes; however, I am beginning to think that the way that I have set up my current class system isn’t very flexible.

My current system has a bunch of subclasses that extend from a interface, each player controller will a class variable that is changed over time as the player changes classes, but I’ve realized that if I want to implement something like a dodge roll, I would have to get the capsule collider of the player object, which is very hard to do with the current system.

I was thinking of doing something like this:

Class playerClass = new Class(this);
// Copy the playerController object into each class object

So I could get full access to all of the variables, but to me it doesn’t seem like a good idea.

How should I get about implementing a character class system that would allow for full flexibility of implementing various things? How do other games like TF2 or Overwatch do this?

Thanks.

There is no “Best” way to code anything thats the beauty of programming it doesn’t matter how you do it as long as it works, and most importantly you understand how it works.

Option 1 “Inheritence Method”

1 Class called “Class”
with a subclass for each class

ex.
public class Mage : Class

Option 2 “Enum method”

public class Player : MonoBehaviour
{
public enum classType {Mage, Warrior, Archer};
public classType playerClass;

}

Option 3 “ScriptableObjects” (I’m guilty of using this a lot more than I probably should)

1 parent class
Public class Class : ScriptableObject {};

as many as you want subclasses
[CreateMenuAsset(menuName = “Class/Mage”)]
public class Mage : ScriptableObject {}