- Home /
Accessing and assigning superclass variables.
I'm a tad bit used to Python, so this is a little difficult for me. I'm trying to create a subclass and reassign some default variables. While it's not impossible to do this in the "Awake" function, its likely I may need to set them before the awake function, so I can accurately collect a list of scripts with the proper IDs set on them.
#pragma strict
class Skill extends MonoBehaviour{ var trained:boolean = false;
var focus:boolean = false;
@HideInInspector
var _relevantModifier:Stats = Stats.INT;
@HideInInspector
var _trainedOnly:boolean = false;
@HideInInspector
var _skillID:SkillID; //Not entirely sure if this is a good idea.
}
And the sublcass:
class Acrobatics extends Skill{
_skillID = SkillID.Acrobatics;
}
What I end up getting is a compiling error which says "expecting }, found '_skillID'".
Is there a better way to do what I'm trying to do?
Answer by oxium · Oct 28, 2011 at 09:09 AM
you have to do that in the constructor of your Acrobatics class
also just a suggestion but if you're starting a new language, you should directly use c# (with the free and awesome monodevelop tool suite)