Question by
unity_WsWzkaLaSL0UMA · Feb 04 at 10:04 AM ·
scripting probleminheritancespellskeyboard shortcut
Dynamic spells and keybindings
So, I'm building a dungeon crawler with 4 bindable spell slots. Each slot can have any of the spells in game.
I was thinking of working with inheritance, having one main spell which all other spell derives from, but as I need the script to have the MonoBehaviour, I can't do that.
As it is right now I have a prefab for each spell with it's script on it, I then instantiate that prefab when I "cast" a spell, but this means that I can't make the keybindings dynamic as I can't cast these spells from one line on code.
I hope you understand my question
I would like to have something that says
public Spell firstSpell;
firstSpell = new ProjectileSpell();
public void Cast()
{
if(firstSpellReady)
{
Cast(firstSpell);
firstSpellReady = false;
firstSpellCooldown = firstSpell.timer;
}
}
Or something that I haven't thought of that works better in this situation.
Comment