Switching between spells (NOT THE VISUAL)
I have a list of "spells", which is a script with a couple of variables such as the name of the spell and the damage of the spell (and so on). I want to be able to switch between the different spells.
I was thinking to have a "activeSpell" variable, that I can change to other "spellPresets" from the spell-list. But I was wondering if there was a better way to do this.
Answer by Zarteke · Jan 02, 2017 at 11:10 PM
It is probably a good idea to save those spells as ScriptableObjects so you can easily edit them and reference them from script, but the way you do it is basically as you described: Store them on a list, and fetch them from the list as you need them. If you only have one spell "selected" at a time it could be as simple as an integer that would store the index of the desired spell on the list.
Unity actually has a training session on this topic: https://unity3d.com/pt/learn/tutorials/topics/scripting/ability-system-scriptable-objects
Answer by RobAnthem · Jan 02, 2017 at 11:03 PM
The activeSpell idea would be the correct way of doing this.
Your answer
Follow this Question
Related Questions
Weapon Select Menu 0 Answers
Sprites being skipped over in sprite change script 1 Answer
If object is active, destroy text 0 Answers
Randomize text position for 2D Quiz C# 0 Answers
When I crouch and move at the same time the player jitters? 0 Answers