inheritance with Unity
I'm making a game with two kinds of characters (or units). Both character types will inherit from a public abstract class called CharacterManager (I'll call it CM for short). In the CM I declare a lot of public variables that will be shared in both kinds of units (ie: health, attack, defense, level, speed, etc). Both unit types have separate scripts that inherit and have constructors that will need to access the health, attack, defense, level (etc) variables. However, my rookie tendencies are coming into effect and I cannot figure out how to make my constructor in my Character1 (child of CM) and my constructor in my Character2 (another child of CM) contain the variables from the parent class.
If you are confused please tell me and I can try and give more specific details.
Thanks!
If the variables are public or protected, you can directly access them (use this.variable
to trigger autocompletion in your IDE).
@Hellium thanks for responding I'm attaching some pics of my code but it appears using this.variable is giving me the issue as follows "does not contain a definition for 'VARIABLENA$$anonymous$$E' and no extension method 'VARIABLENA$$anonymous$$E' accepting a first argument of type 'SCRIPTNA$$anonymous$$$$anonymous$$CLASSNA$$anonymous$$E'
Pokemon
does not inherit from Characters$$anonymous$$anager
so you can't access character name, but Pokemon$$anonymous$$anager
could. This attribute should be in a class called Character
the Pokemon
class will inherit from.
Note : please, edit your question and copy-paste the code ins$$anonymous$$d of attaching images.