Concurrent node to exit when FSM stops

NodeCanvas Forums General Discussion Concurrent node to exit when FSM stops

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #9093

    Hello.

    I have been working with nested FSMs lately and I often find that I could really use a node that where run when the FSM stops. For doing various cleanup etc. and I figured that running a Concurrent node in the FSM and putting a custom action with the cleanup code in the OnStop override should work. And it kind of does too, the only problem is that the OnStop method also gets called every time i ENTER the FSM.

    This is one custom action that I have been using:

    Got any advice on what might be causing the OnStop to get called when I enter the FSM or any ideas on how to achieve the same in a better way?

    Note: I have also tried it without overriding OnExecute and OnUpdate with the same result.

    #9099
    Gavalakis
    Keymaster

    Hello and sorry for this late reply.

    Using the Concurrent node to run some functionality OnStop is definetely a correct way of doing it.
    OnStop is called whenever the action is stopped due to any reason. So the reason why OnStop is called twice in your case, is because you call EndAction again within OnStop. So it’s called once when you call EndAction and another time when the nested FSM exits.

    To achieve what you want to do, you can simply do this:

    Adding this on a Concurent node and when the nested FSM is exited, “Stoped” will be loged.
    Let me know if this works for you.

    Cheers!

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

    #9098

    Hello again.

    Thank you for all the great help you are giving, it really is appreciated. And a reply given on a sunday can not be late 🙂

    As you can see in the example I have sent you by email, whitch is very close to what I am doing in my project.
    The Cleanup action is invoked when the nested FSM is entered as well as when it’s exited.
    Entering one nested FSM and the switching to another calls the Cleanup a total of three times when it should only have been called once ( when i exited the first nested FSM ).

    Hope this clarifies the issue i have a bit better.

    #9097
    Gavalakis
    Keymaster

    Hello again 🙂

    Thanks for sending me the reproduction project. So I’ve found the issue, but not the solution yet. The problem is due to the order that OnGUI is called and how events are received. I am searching for solution and will post it here as soon as possible.

    Thanks

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

    #9096
    Gavalakis
    Keymaster

    Here is a temporary solution:
    Please open up FSM.cs and at line #86 in method EnterState right after the (newState == null) check please add the following:

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

    #9095

    Thanks, just tested it and it seems to work. Really appreciate it 🙂

    #9094
    Gavalakis
    Keymaster

    You are welcome and thanks for helping 🙂

    I will include the proper fix in the next update.

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

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