I want to make a Spell system where i can easy change the spells. For Example, you are playing a Warrior so you have skills a,b,c but if you choose to be a Mage you have x,y,z skills.
Is there an option to make something like a GameObject just for a Script?
I guess you could make a script called ‘Spells’ and then in your ‘Player’ script you would want to make a reference to this script.
Spells spells;
void Start() {
spells = GetComponent<Spells>();
}
Then you could make each spell as a public function in the ‘Spells’ script so you can call them from your ‘Player’ script. Eventually you’d want to check the player’s class before casting any of these spells. I suggest you do this using a switch somewhere and then inherit the correct spells according to the class.
string class = "Warrior";
switch (class) {
case "Warrior":
// Allow the warrior spells
break;
case "Mage":
// Allow the mage spells
break;
}
I’m sure you’ll find a way around this. Also check the code for typos etc. Hope this could help in any way.