Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request/Bug] Enhanced Error Messages #56

Open
vaulcul opened this issue Nov 4, 2024 · 1 comment
Open

[Feature Request/Bug] Enhanced Error Messages #56

vaulcul opened this issue Nov 4, 2024 · 1 comment

Comments

@vaulcul
Copy link

vaulcul commented Nov 4, 2024

I've got a fairly large state machine, and it works for most everything I've been doing. However, I'm currently getting an error and am having a VERY hard time tracking down the line of code that is the culprit (again, large state machine). If the error had some more information as to where it originated from, I think it would be way more useful. It would be nice if it referenced the line or name of the state machine, state, or transition that is causing the error.

Here is the error that needs clarity:

StateMachineException: 
Context: Running OnEnter of the state machine.
Problem: No start state is selected. The state machine needs at least one state to function properly.
Solution: Make sure that there is at least one state in the state machine before running Init() or OnEnter() by calling fsm.AddState(...).

UnityHFSM.StateMachine`3[TOwnId,TStateId,TEvent].OnEnter () (at Assets/UnityHFSM-v2.1.0/src/StateMachine/StateMachine.cs:400)
UnityHFSM.StateMachine`3[TOwnId,TStateId,TEvent].ChangeState (TStateId name, UnityHFSM.ITransitionListener listener) (at Assets/UnityHFSM-v2.1.0/src/StateMachine/StateMachine.cs:215)
UnityHFSM.StateMachine`3[TOwnId,TStateId,TEvent].OnEnter () (at Assets/UnityHFSM-v2.1.0/src/StateMachine/StateMachine.cs:386)
UnityHFSM.StateMachine`3[TOwnId,TStateId,TEvent].ChangeState (TStateId name, UnityHFSM.ITransitionListener listener) (at Assets/UnityHFSM-v2.1.0/src/StateMachine/StateMachine.cs:215)
UnityHFSM.StateMachine`3[TOwnId,TStateId,TEvent].RequestStateChange (TStateId name, System.Boolean forceInstantly, UnityHFSM.ITransitionListener listener) (at Assets/UnityHFSM-v2.1.0/src/StateMachine/StateMachine.cs:264)
UnityHFSM.StateMachine`3[TOwnId,TStateId,TEvent].TryTransition (UnityHFSM.TransitionBase`1[TStateId] transition) (at Assets/UnityHFSM-v2.1.0/src/StateMachine/StateMachine.cs:319)
UnityHFSM.StateMachine`3[TOwnId,TStateId,TEvent].TryAllDirectTransitions () (at Assets/UnityHFSM-v2.1.0/src/StateMachine/StateMachine.cs:355)
UnityHFSM.StateMachine`3[TOwnId,TStateId,TEvent].OnLogic () (at Assets/UnityHFSM-v2.1.0/src/StateMachine/StateMachine.cs:414)
Update () (at Assets/Scripts/CharacterController.cs:566)
@vaulcul
Copy link
Author

vaulcul commented Nov 5, 2024

I think I found what these were during my troubleshooting.

I am using enums instead of text fields for my states. These errors were for the items that were marked as NONE in the enum. I had associated a state machine with the enum when there weren't any states in the state machine. It would still be nice to have some idea of what is being referenced in the error. This was maddening trying to find what was wrong.

The difference between these is what got me:

climbingstatus.AddState(CharacterClimbStatus.None);
climbingstatus.AddState(CharacterClimbStatus.Move, climbingmovement);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant