UniState for character states #113
-
|
I read the section about performance, and according to the documentation UniState seems to be much faster than a typical state implementation using MonoBehaviour. However, in my case I want to use UniState to manage the Player's state in Unity (Idle, Moving, Attack,..). Would using the regular Update() loop be more optimal, or using UniState instead? From some discussions I found online, it seems that continuously updating states in Update() might perform better than using UniTask.Yield() for state updates. Is that correct? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Yes, UniState is a better choice than a MonoBehaviour-based state machine, but if your player FSM is very small and can live in one Update() with a simple switch, that will still be the cheapest option in raw performance. If you go with UniState here, I suggest bind states as singletons and disable history on state machine for your case. |
Beta Was this translation helpful? Give feedback.
Yes, UniState is a better choice than a MonoBehaviour-based state machine, but if your player FSM is very small and can live in one Update() with a simple switch, that will still be the cheapest option in raw performance.
For something like Idle / Move / Attack, I would keep plain Update() if the logic is small. But if you expect the state machine to grow, I would use UniState, because the overhead stays small while the code becomes much easier to scale and maintain.
If you go with UniState here, I suggest bind states as singletons and disable history on state machine for your case.