How to transition between child and parent states in HSM? #249
-
Basically I have a movement state and an attack state as a child. I want to change from movement to attack and viceversa. Can this be done? It seems add_transition just works with direct child states, and change_active_state gives me this error: "Unable to perform transition to a state that is not a child of this HSM."... Don't know what to do because I can't find anything on the docs, all examples seem to be for basic FSM. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Can you provide an example of your state hierarchy? |
Beta Was this translation helpful? Give feedback.
LimboState
is not a composite state, so it cannot contain other states as children (you could use class inheritance instead if you want to share some functionality). Adding more states under vanillaLimboState
not going to work. AndLimboHSM
is a composite that can have exactly one child substate active. We call it active substate. Think of it like a switch - only one of the children states is allowed to be active. And this is what transitions do - switch the active substate on a level.LimboHSM
is a state itself (inherits fromLimboState
), so you can nest them like so: