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

[Bug] Statemachines inside parallel states don't react to global triggers #48

Open
TdXYZ opened this issue Jun 1, 2024 · 0 comments
Open

Comments

@TdXYZ
Copy link

TdXYZ commented Jun 1, 2024

Given the following statemachine configuration:

private StateMachine _stateMachine;

void Start()
{
    StateMachine a = new();
    a.AddState("A");
    a.AddState("B");
    a.AddTriggerTransition("T", "A", "B");
    a.AddTriggerTransition("T", "B", "A");

    StateMachine b = new();
    b.AddState("C");
    b.AddState("D");
    b.AddTriggerTransition("T", "C", "D");
    b.AddTriggerTransition("T", "D", "C");

    _stateMachine = new StateMachine();
    _stateMachine.AddState("root", new ParallelStates(a, b));
    _stateMachine.Init();
}

Using _statemachine.Trigger("T") will not cause a and b to perform their transitions. This unfortunately makes ParallelStates useless for statemachines that rely heavily on trigger transitions.

This can be fixed by having ParallelStates implement ITriggereable. There is however a potential issue that should be addressed. Say that statemachine "a" has some nested statemachines and statemachine "b" has a transition whose guard checks ActiveStateName of one of those nested machines. An Exception will be thrown if the nested machine is not the active state of its parent machine.

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