Bug in ButtonClicked Condition?

NodeCanvas Forums General Discussion Bug in ButtonClicked Condition?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12223
    modernalchemists
    Participant

    I got a FSM with 4 states, one being a sub FSM.
    I use one button (“skip to next state”) which triggers through the state machine for debugging each state.

    All works well in the first run.
    The last state optionally returns to the first state and this is where it starts to fall appart … but I think I fixed everything.

    Part of it was my code, but I also had to change the ButtonClicked condition, as something was wrong with the listener (was called twice in the second run).
    Cand you confirm this?

    #12226
    Gavalakis
    Keymaster

    Hello,

    Hmm. For the event to be raised twice, it means that the OnInit is also called twice, but OnInit should really only be called once in the code. I tried reproducing a case where it could be called more than once but (thankfully )didn’t really happen.
    Do you by any chance, have the same UI button reference on more than one ‘ButtonClicked ‘ conditions which are one right after the other?
    What I mean by that, is something like the following image. In this case, even a single click at the button (which is the same), will instantly make two transitions, since at the time the button is clicked, both of the conditions are true.

    Let me know if that is indeed the case, or something completely different.
    The change you’ve made by the way, is fine and should work fine as well. I am just trying to figure out what is the cause 🙂

    Thanks.

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

    Attachments:
    You must be logged in to view attached files.
    #12236
    modernalchemists
    Participant

    Hi, yes, that is indeed the case.
    So is this intended behavior or should I understand what’s going on behind the scenes?

    Thanks!

    #12251
    Gavalakis
    Keymaster

    Hello,
    This is an expected behavior due to how events like this work, but some times it is also not the indented one as well. 🙂
    For an easier alternative fix to your code, please open up ConditionTask.cs instead and change method YieldReturn line #71, to the following:

    Let me know if that works for you.
    Thanks!

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

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