Hey so I’m not sure if this is the best place to ask this but it does relate to scripting so I figured I’d ask it here.
Anyway so in my game I currently have a spell system I designed. It has a core spell class which every spell has as well as various different spell components which perform different actions. The purpose of the spell class is to relay different events to specific components. Such as Collisions, Spell Apply(performing an action on an Entity), Updates etc. Each spell component can be set to perform its action in response to a specific event and specific components have an option to accept a target as a parameter.
Essentially it is an event based system where specific components trigger events and other components respond to them. It is setup so you can easily add components which can completely alter the behaviour of the spell. Also due to how components are designed you can easily change the behaviour of spells by altering what events different actions respond to.
My question is, would a system like this be well for a top down spell casting game or should I look at something like Behaviour Designer or NodeCanvas for handling spell behaviour. Keeping in mind the spells need to perform different actions on different events. For example on collision the particle system should emit. The system works well but doesn’t leave room for much complex behaviour.
My worry for using a behaviour tree is would not work well when many spells are active in the scene. I also worry that it would over complicate something which might not really need to be so complex. At the same time there would be cases where I would want spells to behave in potentially more complex ways and to add in these behaviours I would have to develop execution control over when events are accepted based on conditions which almost seems pointless if I just used behaviour designer.
This is a link to my game just so you can get an idea of how often spells are used and how many could be active at a given time.
I’ve used Behaviour Designer for my game AI I’ve just created scripts for them to use. I find it to be a nice means of handling game logic. Also I realise NodeCanvas has a state machine but I’m thinking more in terms of the Behaviour Tree end of things rather than a state machine.
For example in Behaviour Designer I can have a motor remain inactive until an Entity gets within a certain distance after which I could have it execute a specific branch and change the behaviour of the spell completely. In Essence I could get a spell to orbit around using an orbit motor and when an enemy comes within distance I could have it behave to use a homing missile motor, changing the behaviour of the spell completely without having to hard code a dependency in the orbit missile motor. Which in my eyes just seems like bad coding practice.
I’m not looking to use a state machine for this though since it needs to execute parallel tasks. The question is, is this too complex a means for use with spells. I’m not quite well versed with Behaviour Designer yet so I don’t know if creating a bunch of parallel tasks and listening for specific events would be considered a misuse.
That is state machine actually. It might be called ‘behaviour tree branch’, but what that tree does is describe state changes and what’s done inside states. Changing state can be as easy as remove old spell GameObject and spawn new one while copying some values you might need(like previous speed, position and rotation) if you like that way. It also can be an switch(state){case State.ORBIT:…} statement in C#. Or it can be moving in behaviour tree to another node. I don’t see difference, actually.
Then don’t do it. You’re making it, your rules.
Like what? I don’t think a spell (especially projectile) can do more than one thing at once. Target spells, AOE spells can’t. Summons maybe, but they need A.I. and that’s separate discussion. What can spells do other than create prefab, affect area, affect target, move? What checks do they need other than “in the area”/“on hit”?
The question is, will this complexity slow you down? Or will it help you? Is it a necessary devil or a helping angel? If it’s neither necessary or helping, then discard it.
Behaviour Designer is just another way of writing scripts. If it works, it’s not misuse. If you like making code there, then do it. If you don’t, then falling back to other solutions/C# is always an option.
In any case, just use whatever will bring you to completed game fastest. I don’t know what you do fastest, neither anyone on forums do, so make a decision.
Both in combination would be a good solution. Use your current spell system to cast spells. Use a behavior tree to tell your NPCs which spells to cast and when to cast them.
Write a custom behavior task that tells the spell system to cast a spell. This will serve as the interface between your behavior tree and your spell system.