/// <summary> /// Tests if this motion should be started. However, the motion /// isn't actually started. /// </summary> /// <returns></returns> public override bool TestActivate() { // If we're not startable, this is easy if (!mIsStartable) { return(false); } // If we're not grounded, this is easy if (!mActorController.IsGrounded) { return(false); } // Ensure we have input to test if (mMotionController._InputSource == null) { return(false); } // If we're not wanting to jump, this is easy if (!mMotionController._InputSource.IsJustPressed(_ActionAlias)) { return(false); } // Ensure we're in a valid starting motion if (mMotionLayer.ActiveMotion != null) { IWalkRunMotion lWalkRunMotion = mMotionLayer.ActiveMotion as IWalkRunMotion; if (!(mMotionLayer.ActiveMotion is BalanceWalk) && (lWalkRunMotion == null || !lWalkRunMotion.IsRunActive)) { return(false); } // Test if we're actually running mWalkRunMotion = lWalkRunMotion; } // We need to be running "forward" for this jump if (mMotionController.State.InputForward.magnitude < 0.5f || Mathf.Abs(mMotionController.State.InputFromAvatarAngle) > 10f) { return(false); } // The motion may not be active, but the animator may not have moved // out of the IdlePose yet. Wait for it to transition out before we allow // another jump. int lStateID = mMotionController.State.AnimatorStates[mMotionLayer.AnimatorLayerIndex].StateInfo.fullPathHash; if (lStateID == STATE_IdlePose) { return(false); } // We're good to move return(true); }
/// <summary> /// Initialize is called after all the motions have been initialized. This allow us time to /// create references before the motions start working /// </summary> public override void Initialize() { if (mMotionController != null) { if (mWalkRunMotion == null) { mWalkRunMotion = mMotionController.GetMotionInterface <IWalkRunMotion>(); } //if (mWalkRunPivot == null) { mWalkRunPivot = mMotionController.GetMotion<WalkRunPivot>(); } //if (mWalkRunPivot_v2 == null) { mWalkRunPivot_v2 = mMotionController.GetMotion<WalkRunPivot_v2>(); } //if (mWalkRunStrafe == null) { mWalkRunStrafe = mMotionController.GetMotion<WalkRunStrafe>(); } //if (mWalkRunStrafe_v2 == null) { mWalkRunStrafe_v2 = mMotionController.GetMotion<WalkRunStrafe_v2>(); } //if (mWalkRunRotate == null) { mWalkRunRotate = mMotionController.GetMotion<WalkRunRotate>(); } //if (mWalkRunRotate_v2 == null) { mWalkRunRotate_v2 = mMotionController.GetMotion<WalkRunRotate_v2>(); } } }
void IsRun() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } mMotionController = go.GetComponent <MotionController>(); IWalkRunMotion lMotion = mMotionController.ActiveMotion as IWalkRunMotion; if (mMotionController != null && lMotion != null) { store.Value = lMotion.IsRunActive; Fsm.Event(lMotion.IsRunActive ? trueEvent : falseEvent); } }