Applying stats/abilities to a GameObject, and knowing which ones I did so to?

Hi, all. I’m working on an RPG-style game. In the game, I have classes (like Warrior or Mage) and abilities (like Slash or Fireball or Heal). I’ve set up a factory-style implementation for ability creation, and something similar to it for class creation. Here’s an example of each:

Ability factory:
public class AbilityFactory {
///


/// The Warrior’s basic slash ability.
///

public static AttackAndHealAbilities Slash() {
setName = “Slash”; //ability name
string setDescription = “A simple cutting attack.”; //ability description
string iconName = “SlashAbility”; //ability thumbnail

int damage = 1; //Damage the ability does. Use a negative number for healing.

//Do not edit this. Edit the corresponding variables above instead.
return new AttackAndHealAbilities(setName, setDescription, iconName, damage); }
Class creation:
public class Warrior {
///


/// Creates a Warrior-class unit.
///

public static BaseCombatClass WarriorClass() {
string setName = “Warrior”; //String to be used as the class name.
string setDescription = “A skilled fighter.”; //Description of the class.
string iconName = “WarriorClassArt”; //class thumbnail

int setMaxHP = 10; //Maximum HP
int setCurrentHP = 10; //Current HP
int setDef = 0; //Unit’s defense value

//Do not edit this. Change the corresponding variable above instead.
return new BaseCombatClass(setName,setDescription,iconName,setMaxHP,setCurrentHP,setDef); } }

Obviously there’s more variables than that, but you should get the idea of what my implementation is like. However, this is about as much as I know about OOP. What I’m wondering is, how do I make my game know that the WarriorClass stuff applies to a specific unit/Game Object, and how do I make an ability know who used it and who it was used on, so that it knows whose health to modify when used?

bump since it’s been just shy of a day

First off, props for putting all your formatting in so carefully for the code. Next time, though, just use code tags…it has the added bonus of line numbers.

I think you haven’t gotten any answers because you ask a lot of questions about how to generally make a game, rather than for help troubleshooting a specific problem, and they’re rather vague. It seems like maybe you should follow the scripting tutorials in the Learn section. Most of what you want to know can be picked up from there.

Look into ScriptableObjects. You can create assets in your project files to hold this data config stuff, and then you can have your scripts hold a variable reference to the scriptable object asset.

Create numerous Ability objects, and have your character store a list of Ability objects. Or one reference to a Class object, etc.