Having nextState for FSM

NodeCanvas Forums Support Having nextState for FSM

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #12127
    Driiade
    Participant

    Hello, can you add the next state in FSM to use it in the OnExit() function ?

    #12129
    Gavalakis
    Keymaster

    Hello,

    I am sorry, but I am not sure I understood the question.
    Can you please clarify what you mean? 🙂

    Thanks.

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

    #12134
    Driiade
    Participant

    Sure.

    For the moment we have previousSate and currentState. But I want to created “ConditionnedAction” and the condition will be : “If the previousState is … launch action”, or “If the nextState is…launch action”. I will use this with SuperActionState in the onEnterActionList and onExitActionList. But i need the nextState the moment where the exitActionList is called.

    Same thing, on the OnExit() of a state, it will be cool to have the next state, for doing different thing at this moment depending of the next state.

    #12141
    Gavalakis
    Keymaster

    Ok I understand what you mean now.
    Even though I think it is generally not a very good design approach to handle things on exit, based on what the upcomming state would be (maybe Im wrong), it is something easy to add.
    Please do the following changes in FSM.cs just to confirm that is indeed what you are after and let me know.

    1) Add public FSMState nextState{get; private set;} in the class.
    2) In EnterState method and right after the first two checks, add nextState = newState; so that the code looks like this:

    Let me know.
    Thanks.

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

    #12144
    Driiade
    Participant

    Hum, I don’t known if it’s a good design. But i use it when, for example, my character is in a particular state and in this state an action has to be done if it go to a specific state. But It does it only if it will go on this specific state.

    But I can put the action in the beginning of the specific state with a previousState check, but I think it’s conceptually incorrect… Maybe I’m wrong or not…

    #12157
    Gavalakis
    Keymaster

    Hello,

    I would personally put the desired action at the beginning on the next sate, instead of at the end of the current one. 🙂
    You can also add an intermediate state that has the action you want attached, but of course that is not ideal since it needs extra states to be created solely for this reason.

    Does making this change to the code provides what you want to do?
    If so I can add a “nextState” property in the next version. Just let me know of so.

    Thanks.

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

    #12159
    Driiade
    Participant

    Oh yeah the code is great.

    Make sure nextState = null at the end of the function. nextState has to be undefined in Update.

    For the moment i don’t use it, i have to refactoring my code for testing if it is robust.

    I also have done a ConditionnedAction :

    This was designed to be used with previousState and nextState condition. I will keep you informed if it worked great =) .

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