//////////////////////////// ////////// Method ////////// //////////////////////////// ///////////////////////// ////////// API ////////// /// <summary> /// Initialize the motion state machine /// </summary> public void Initialize(ACharacterSystem cs) { if (_entryMotionState == null) { Debug.LogError("[MSM] There is no entry motion state to the motion state machine!"); } else { _currentMotionState = _entryMotionState; } _motionType = cs.GetType().IsSubclassOf(typeof(ACharacterSystem3D)) ? EMotionType.Motion3D : EMotionType.Motion2D; }
/// <summary> /// Update the current motion state /// </summary> public void Update(ACharacterSystem cs, MotionInformation mi) { if (_currentMotionState == null) { return; } var nextMotionState = _currentMotionState.AttemptToGetNextMotionState(cs, mi, _motionType); if (nextMotionState != null) { _previousMotionState = _currentMotionState; _currentMotionState = nextMotionState; if (ShouldDisplayDebugTransitionLog) { DisplayDebugTransitionLog(); } } }