So I am struggling a bit with a really well oiled Spell casting system. I have one in place right now that works, but it is clumsy and error prone.
Here are the horrid details:
-I have a spell object which contains all the spells info (duration, damage, type (self, area, target based), recast time, etc…) - so far so good.
-The spell object also contains a reference to three prefabs, a “casting” effect, a “flight” effect, and a “hit” effect.
-when the user casts a spell, the caster enters a “casting state” until the casting is done (I also instantiate the “casting” prefab (casting effect). This in turn instantiates the flight prefab (if applicable) which in turn instantiates the “hit” prefab (when a target is hit). I pass a spell info object between these prefabs which contains the target AND source info so I can try who cast the spell and who/what the target is (can be null if its an area of effect spell).
As you can imagine this “workflow” is terrible to maintain.
Has anyone else implemented a spell casting system? Its need to be flexible in that it doesn’t matter who is casting (enemy or player) or what the target is as enemies can fight one another.