I am trying to create a spell casting system for an auto chess game.

I find myself not knowing which direction to go in my design. I started out with a Spell as a scriptable object that contains a list of spell effects (damage, heal, etc). Each effect can spawn a game object (usually some sort of particle effect) to indicate the cast.

This started to get a bit complicated and I began wondering if I am going about this the wrong way. The second attempt was an abstract spell class where I'd create concrete spells from it (lightning blast, fireball, for example). When the cast animation completes on the unit, it would call spell.Cast() and the concrete class would take care of the rest. The downside is two fold:

  1. The unity editor doesn't seem to let me put a derived class in the "spell" slot since I said it would be of type Spell (the abstract class).
  2. This will certainly result in a large number of classes... not sure this matters as the other way will give me lots of scriptable objects.

When I encounter this many issues with something like this, I start to wonder if I am designing something wrong. Am I missing a super easy way to do this?

  • When you say "scriptable object", do you mean literally there is a scripting language you can use to define the behavior? Dec 27, 2022 at 14:28
  • 1
    Or are you talking about ScriptableObject? Dec 27, 2022 at 15:16
  • Are you able to use interfaces with a ScriptableObject or abstract Spell? Dec 27, 2022 at 19:42


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.