hello devs, I want to know if there is a way of tracing animations states, for instance my application needs to know which was the prior state of animation before switching to state x.

Hello how are you doing guys, i have an AI agent set up in my scene who runs down the base camp of enemies and accomplishes his tasks, now while he’s running if he comes in a range of enemies they shoot at him and if an agent gets hit , an animation of getting hit is played once that animation is complete the agent should resume the running,
now the agent may get hit in any state, be it in idle or running, i need to know from which state agent goes to “getting hit” state so that i could force it going back into the prior one once “getting hit” state is completed.

forexample
x=currentstate -----> y=gethitstate -------> x

Properties would be pretty useful here. This is an C# example

    AIState _currentState;
    public AIState currentState
    {
        get
        {
            return _currentState;
        }
        set
        {
            if (value != _currentState)
            {//A new value is assigned, so update the previousState
                _previousState = _currentState;
            }
            _currentState = value;
        }
    }

    AIState _previousState;
    public AIState previousState
    {
        get
        {
            return _previousState;
        }
    }


public enum AIState {
Walking,
Attacking,
Talking
}

This would make a public read-only variable previousState. And you could just assign the current state variable, even in update, and it will automatically keep track of the previousState.

Hope you learned something!

-Gameplay4all