Best practices?

NodeCanvas Forums General Discussion Best practices?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8991
    karmelov
    Participant

    Hello,

    First of all I want to thank you for this tool. I got it from the store and I’m going to use it for my project, but before replacing my current scripted AI, I want to make sure I take full advantage of NC’s potential.

    Right now I have a couple of really simple AIs:
    -One that wanders around and runs away from you once the player gets close to it.
    -One that looks for the player, and chases him.

    The AI is currently working through different MonoBehaviours:
    -I have a BaseActor script for all AI actors, that setup basic functions, such as taking damage. Basically this script defines what the actors can do.
    -Each AI has its own script that defines its own behaviour. This script decides what the AI will do. It works with the help of the FSM provided by Animators.

    For example:
    If the player presses the attack button, the script will set the parameter “attacking” in the animator to true. If the animator is in a state with a transition to the “attacking” animation, the animation will execute. Then the animation will launch an animationEvent that will disable the controls until the animation ends, sending another animationEvent to enable controls.

    I want to use NC to reproduce my current AI behaviour first, but I’m not really sure what would be the best practice.
    -Should I give up the FSM provided by the Animator, and handle animation execution (like the Attack example) through NC?
    -Should I keep my BaseActor script, and make NC call its functions? Or should I remove my BaseActor script and replace it with custom NC Tasks?

    I know there is not a correct answer, and that it really depends on how I want to manage all the stuff, but I want to understand the boundaries of NC, to make sure I’m not clogging my graphs, or just not making good enough us of them.

    Thanks!

    #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

    #8992
    karmelov
    Participant

    Got it!

    Really excited to see such amazing support for this tool!!
    Keep up the good work.

    Thanks a lot!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.