I’m a bit concerned about creating a new state every time we transition, what if we have some state saved on a state and want to keep it?
#1 How would one use previously created states while transitioning from one to another?
Which brings me to my second question - Why are the states themselves transitioning to a new state? Shouldn’t it be handled by the State Manager? A cartridge is not the one that pulls itself out and put the other one in.
#2 Would something like this be better? Does it break any principle?
public interface ILocomotionState
{
ILocomotionState GetStateFromJump();
}
class LocomotionStatePattern : MonoBehaviour
{
ILocomotionState currentState = new StandingState();
private void Jump()
{
currentState = currentState.GetStateFromJump();
}
}