Reply To: Best practices?

NodeCanvas Forums General Discussion Best practices? Reply To: Best practices?

#8993
Gavalakis
Keymaster

Hello and thanks as well!

What I really tried to do with NC and thus is what I will suggest, is to make as much as possible for someone to use it on-top of any setup you might have.
So I can certainly suggest you to use your existing MonoBehaviours and use the ScriptControl tasks to get/set properties and execute function on, without creating custom tasks. This way you can keep all your character functionality within a place and simply ‘interface’ with it, but of course, executing functions with these ScriptControl tasks is not as fast (performance wise) as directly using a custom task. The difference though is not that much due to some reflection optimizations.

Furthermore, using custom tasks you have some extra execution control like OnInit, OnExecute, OnUpdate OnPause and OnStop, but a lot of actions don’t really need to make use of those, which mostly depends on your setup.
Even if you do choose to create custom tasks, you can still keep all functionality in your monobehaviour and simply create wrapper tasks, which execute that function on your monobehaviour, instead of creating a task that contains the functionality. This makes it more managable in the long run.

So, at least in my personal taste, an action or condition task should be a wrapper to your own code, and a graph should be responsible for managing this code/functionality flow. My opinion is this matter, is very much contradictory to what many other visual scripting/AI tools believe though 🙂

Now as far as for keeping the Mecanim FSM, I should definetely say yes due to the above reasons, since you can easily check if the controls are enabled or disabled with a CheckProperty condition task.

So, in the end, I would say this. Don’t try to create the game for NC, but instead use NC for your game. 🙂

Let me know if you want to elaborate more, or if you have any further questions. I’d be glad to answer them.

Best regards,
Gavalakis Vaggelis

Join us on Discord: https://discord.gg/97q2Rjh