/// <summary> /// Called to start the specific motion. If the motion /// were something like 'jump', this would start the jumping process /// </summary> /// <param name="rPrevMotion">Motion that this motion is taking over from</param> public override bool Activate(MotionControllerMotion rPrevMotion) { mStopTime = 0f; mStopInput = Vector2.zero; mLinkRotation = false; // Helps with syncronizing from a motion like attack float lRunFactor = (IsRunActive ? 1f : 0.5f); mInputX.Clear(mMotionController.State.InputX * lRunFactor); mInputY.Clear(mMotionController.State.InputY * lRunFactor); // Update the max speed based on our animation mMotionController.MaxSpeed = (_RunSpeed > 0f ? _RunSpeed : 3.2f); // Determine how we'll start our animation mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, true); // Register this motion with the camera if (_RotateWithCamera && mMotionController.CameraRig is BaseCameraRig) { ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated; ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated; } // Finalize the activation return(base.Activate(rPrevMotion)); }
/// <summary> /// Called to start the specific motion. If the motion /// were something like 'jump', this would start the jumping process /// </summary> /// <param name="rPrevMotion">Motion that this motion is taking over from</param> public override bool Activate(MotionControllerMotion rPrevMotion) { mIdleTime = 0f; mIsRotationLocked = false; mInputX.Clear(); mInputY.Clear(); mInputMagnitude.Clear(); // Update the max speed based on our animation mMotionController.MaxSpeed = 5.668f; // Start the motion mActiveForm = (_Form >= 0 ? _Form : mMotionController.CurrentForm); mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, mActiveForm, 0, true); // Register this motion with the camera if (mMotionController.CameraRig is BaseCameraRig) { ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated; ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated; } // Finalize the activation return(base.Activate(rPrevMotion)); }
/// <summary> /// Called to start the specific motion. If the motion /// were something like 'jump', this would start the jumping process /// </summary> /// <param name="rPrevMotion">Motion that this motion is taking over from</param> public override bool Activate(MotionControllerMotion rPrevMotion) { mIdleTime = 0f; mLinkRotation = false; mInputX.Clear(); mInputY.Clear(); mInputMagnitude.Clear(); // Update the max speed based on our animation mMotionController.MaxSpeed = 5.668f; // Determine how we'll start our animation mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, true); // Register this motion with the camera if (_RotateWithCamera && mMotionController.CameraRig is BaseCameraRig) { ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated; ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated; } // Finalize the activation return(base.Activate(rPrevMotion)); }
/// <summary> /// Called to start the specific motion. If the motion /// were something like 'jump', this would start the jumping process /// </summary> /// <param name="rPrevMotion">Motion that this motion is taking over from</param> public override bool Activate(MotionControllerMotion rPrevMotion) { mNoInputElapsed = 0f; mLinkRotation = false; // Force the stance mSwimmerInfo.EnterWater(); if (rPrevMotion is Jump || rPrevMotion is Fall) { mSwimmerInfo.CreateSplash(); } // Helps with syncronizing from a motion like attack float lRunFactor = (IsRunActive ? 1f : 0.5f); mInputX.Clear(mMotionController.State.InputX * lRunFactor); mInputY.Clear(mMotionController.State.InputY * lRunFactor); mInputMagnitude.Clear(Mathf.Sqrt((mInputX.Value * mInputX.Value) + (mInputY.Value * mInputY.Value))); // Determine how we'll start our animation mMotionController.ForcedInput = Vector3.zero; mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, true); // Register this motion with the camera if (_RotateWithCamera && mMotionController.CameraRig is BaseCameraRig) { ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated; ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated; } // Finalize the activation return(base.Activate(rPrevMotion)); }
public void Clear() { floatValue.value = 12f; floatValue.Clear(); Assert.AreEqual(floatValue.value, 0.0f); }
/// <summary> /// Updates the motion over time. This is called by the controller /// every update cycle so animations and stages can be updated. /// </summary> /// <param name="rDeltaTime">Time since the last frame (or fixed update call)</param> /// <param name="rUpdateIndex">Index of the update to help manage dynamic/fixed updates. [0: Invalid update, >=1: Valid update]</param> public override void Update(float rDeltaTime, int rUpdateIndex) { mRotation = Quaternion.identity; // Grab the state info MotionState lState = mMotionController.State; // Convert the input to radial so we deal with keyboard and gamepad input the same. float lInputX = lState.InputX; float lInputY = lState.InputY; float lInputMag = lState.InputMagnitudeTrend.Value; InputManagerHelper.ConvertToRadialInput(ref lInputX, ref lInputY, ref lInputMag); //, (IsRunActive ? 1f : 0.5f)); // Ensure we support the stop delay. This way, we can get out // of the blend tree with a nice transition if (lState.InputMagnitudeTrend.Value < 0.4f) { // Only set the timer if it's not set yet if (mStopTime == 0f) { mStopInput.x = mInputX.Average; mStopInput.y = mInputY.Average; mStopTime = Time.time + _StopDelay; mInputX.Clear(mStopInput.x); mInputY.Clear(mStopInput.y); mInputMagnitude.Clear(Mathf.Sqrt((mInputX.Value * mInputX.Value) + (mInputY.Value * mInputY.Value))); } } // Clear the timer else { mStopTime = 0f; } // When we're processing normally, update all the input values if (mStopTime == 0f) { mInputX.Add(lInputX); mInputY.Add(lInputY); mInputMagnitude.Add(lInputMag); } // If we've reached our stop time, it's time to stop else if (Time.time > mStopTime) { // Determine how we'll stop based on the direction if (!(mMotionLayer._AnimatorStateID == STATE_IdlePoseOut)) { mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_STOP, 0, true); } // If we're already stopping, we can clear our movement info. We don't want // to clear the movement before the transition our our blend tree will drop to idle else { mStopTime = 0f; mInputX.Clear(); mInputY.Clear(); mInputMagnitude.Clear(); lState.AnimatorStates[mMotionLayer._AnimatorLayerIndex].MotionPhase = 0; lState.AnimatorStates[mMotionLayer._AnimatorLayerIndex].MotionParameter = 0; } } // Modify the input values to add some lag lState.InputX = mInputX.Average; lState.InputY = mInputY.Average; lState.InputMagnitudeTrend.Replace(mInputMagnitude.Average); // Finally, set the state value mMotionController.State = lState; // If we're not dealing with an ootii camera rig, we need to rotate to the camera here if (_RotateWithCamera && !(mMotionController.CameraRig is BaseCameraRig)) { OnCameraUpdated(rDeltaTime, rUpdateIndex, null); } if (!_RotateWithCamera && _RotateWithInput) { RotateUsingInput(rDeltaTime, ref mRotation); } // Allow the base class to render debug info base.Update(rDeltaTime, rUpdateIndex); }