Minions in the RPG course

Hi Brian,

Thanks for your reply. I havent altered the BaseStats code, its exactly the same as from the course. I was trying to implement the minion level, health and damage from within the minionController class, to keep the logic seperated. Is this not the best approach / not possible?

Cheers

I would keep everything related to health for any unit in the Health.cs, and stats in BaseStats. Otherwise, you wind up having a LOT of corner cases to deal with things like “how do I damage a minion?”…

For example, Fighter.cs shouldn’t have to check to see if it’s target is a minion before applying damage, it should just get the Health component of the target and damage it.

When level is checked, especially from other classes, it should be from BaseStats, same with getting the damage, defense, or whatever other stat you may have.

So… when getting the Level in BaseStats, I would have a bool for IsMinion (or perhaps detect a Minion component on the character?)

public Level GetLevel()
{
    if(experience!=null) return CalculateLevel();
    if(IsMinion) return player.GetLevel();  //get the player in Awake()
    return startingLevel;
}

Hi Brian,

That one simple fix in base stats solved the problem. I knew it would be something simple. Thank you for your time.

Cheers

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms