Skip to content

Incorrect GoBack behaviour #36

@JakBlack

Description

@JakBlack

Repro states

public class State1 : StateBase
{
    public override async UniTask<StateTransitionInfo> Execute(CancellationToken token)
    {
        Debug.Log("State1");
        await UniTask.Yield();
        return Transition.GoTo<State2>();
    }
}

public class State2  : StateBase
{
    private static bool wasPerformed = false;

    public override async UniTask<StateTransitionInfo> Execute(CancellationToken token)
    {
        Debug.Log("State2");
        await UniTask.Yield();
        var state = wasPerformed ? Transition.GoBack() : Transition.GoTo<State3>();
        wasPerformed = true;
        return state;
    }
}

public class State3 : StateBase
{
    public override async UniTask<StateTransitionInfo> Execute(CancellationToken token)
    {
        Debug.Log("State3");
        await UniTask.Yield();
        return Transition.GoBack();
    }
}

State machine execution

Debug.Log("State machine initialized");
await _stateMachine.Execute<State1>(cts.GetRenewedToken());

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);

Resulting output
image

Expected behaviour:

  • GoBack doesn't result in the same state being executed
  • GoBack to first state of the state machine doesn't result in state machine being closed

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions