Inspiaaa / UnityHFSM

A simple yet powerful class-based hierarchical finite state machine for Unity
MIT License
1.05k stars 121 forks source link

Implementation of PriorityTransitions #47

Open ThomasReuss opened 4 months ago

ThomasReuss commented 4 months ago

Dear maintainers, while working through this repo, I came across the following questions / remarks: 1) Why do we have both fsm and parentFSM and then we set parentFSM to be fsm? I do not see the added value of parentFsm in IStateMachine

2) Say I have a class MyState which has a property Priority of type int, and I want to only transition between two states (esepcially in TriggerTransitionFromAny, TransitionFromAny, etc, when fromState.priority <= toState.Priority. The way I am currently implementing this is in a derived MyTransition class and a ShouldTransition override. Here we see a limitation of the expandability of the current base classes. IStateMachine has no GetStateand no ActiveState. This forces me to pass in the StateMachine into the constructor of the transition. Are there any recommended ideas to implement this?

This is essentially a special case when the transition needs to know data from the states to decide whether it should allow a state change. A similar "limitation" is that the StateBase.CanExit() does not know what state it was asked to exit to.