/// <summary>
        /// Pulls an object from the pool.
        /// </summary>
        /// <returns></returns>
        public static MotionReachData Allocate()
        {
            // Grab the next available object
            MotionReachData lInstance = sPool.Allocate();

            // Return it for use
            return(lInstance);
        }
        /// <summary>
        /// Returns an element back to the pool.
        /// </summary>
        /// <param name="rEdge"></param>
        public static void Release(MotionReachData rInstance)
        {
            // Clear the values
            rInstance.StateID            = 0;
            rInstance.TransitionID       = 0;
            rInstance.Power              = 1;
            rInstance.IsReachTargetLocal = false;
            rInstance._ReachTarget       = Vector3.zero;
            rInstance._ReachTargetGround = null;
            rInstance.StartTime          = 0f;
            rInstance.EndTime            = 0f;
            rInstance.IsComplete         = false;

            // Send it back to the pool
            sPool.Release(rInstance);
        }
示例#3
0
        /// <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)
        {
            // Ensure we have good collision info
            if (mRaycastHitInfo.collider == null)
            {
                return(false);
            }

            // Reset the triggger
            mIsExitTriggered = false;

            // Track the object we're trying to climb and store it
            mClimbable = mRaycastHitInfo.collider.gameObject;

            Vector3 lClimbForward = Quaternion.AngleAxis(180, mActorController._Transform.up) * mRaycastHitInfo.normal;

            mFaceClimbableNormalAngle     = mActorController._Transform.forward.HorizontalAngleTo(lClimbForward, mActorController._Transform.up);
            mFaceClimbableNormalAngleUsed = 0f;

            // Setup the reach data and clear any current values
            ClearReachData();

            MotionReachData lReachData = MotionReachData.Allocate();

            lReachData.StateID           = STATE_IdleClimbMid;
            lReachData.StartTime         = 0.2f;
            lReachData.EndTime           = 0.6f;
            lReachData.Power             = 3;
            lReachData.ReachTarget       = mRaycastHitInfo.point + (mActorController._Transform.up * _ReachOffset1) + (mRaycastHitInfo.normal * _ReachOffset2);
            lReachData.ReachTargetGround = mActorController.State.Ground;
            mReachData.Add(lReachData);

            // Disable actor controller processing for a short time
            mActorController.IsGravityEnabled     = false;
            mActorController.ForceGrounding       = false;
            mActorController.FixGroundPenetration = false;
            mActorController.SetGround(mClimbable.transform);

            // Start the animations
            mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START, true);

            // Return
            return(base.Activate(rPrevMotion));
        }
示例#4
0
        /// <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)
        {
            // Ensure we have good collision info
            if (mRaycastHitInfo.collider == null)
            {
                return(false);
            }

            //_IsGravityEnabled = false;
            //mIsGroundedExpected = false;
            mStartPosition = mActorController._Transform.position;

            // Track the object we're trying to climb and store it
            mClimbable = mRaycastHitInfo.collider.gameObject;

            // Disable actor controller processing for a short time
            mActorController.IsGravityEnabled     = false;
            mActorController.FixGroundPenetration = false;
            mActorController.SetGround(mClimbable.transform);

            BodyShape lBodyShape = mActorController.GetBodyShape("Combatant Shape");

            if (lBodyShape != null)
            {
                lBodyShape.IsEnabledOnGround    = false;
                lBodyShape.IsEnabledOnSlope     = false;
                lBodyShape.IsEnabledAboveGround = false;
            }

            Vector3 lClimbForward = Quaternion.AngleAxis(180, mActorController._Transform.up) * mRaycastHitInfo.normal;

            mFaceClimbableNormalAngle     = mActorController._Transform.forward.HorizontalAngleTo(lClimbForward, mActorController._Transform.up);
            mFaceClimbableNormalAngleUsed = 0f;

            // Setup the reach data and clear any current values
            ClearReachData();

            // Set the animator in motion
            if (mRaycastHitInfo.distance < 1f)
            {
                //Quaternion lWallHitRotation = Quaternion.LookRotation(-mRaycastHitInfo.normal, mActorController._Transform.up);
                Quaternion lWallHitRotation = mActorController._Transform.rotation;

                MotionReachData lReachData = MotionReachData.Allocate();
                lReachData.StateID           = STATE_StandClimb_2_5m;
                lReachData.StartTime         = 0.445f;
                lReachData.EndTime           = 0.524f;
                lReachData.Power             = 4;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset1) + (lWallHitRotation * _ReachOffset2);
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                lReachData                   = MotionReachData.Allocate();
                lReachData.StateID           = STATE_StandClimb_2_5m;
                lReachData.StartTime         = 0.6f;
                lReachData.EndTime           = 0.8f;
                lReachData.Power             = 4;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (lWallHitRotation * _ReachOffset3);
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                lReachData                   = MotionReachData.Allocate();
                lReachData.StateID           = STATE_ClimbToIdle;
                lReachData.StartTime         = 0.0f;
                lReachData.EndTime           = 0.5f;
                lReachData.Power             = 4;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (lWallHitRotation * _ReachOffset4);
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START_CLOSE, true);
            }
            else
            {
                //Quaternion lWallHitRotation = Quaternion.LookRotation(-mRaycastHitInfo.normal, mActorController._Transform.up);
                Quaternion lWallHitRotation = mActorController._Transform.rotation;

                MotionReachData lReachData = MotionReachData.Allocate();
                lReachData.StateID           = STATE_Climb_2_5m;
                lReachData.StartTime         = 0.0f;
                lReachData.EndTime           = 0.1f;
                lReachData.Power             = 3;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset5) + (lWallHitRotation * new Vector3(0.0f, 0f, 0f));
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                lReachData                   = MotionReachData.Allocate();
                lReachData.StateID           = STATE_Climb_2_5m;
                lReachData.StartTime         = 0.1f;
                lReachData.EndTime           = 0.216f;
                lReachData.Power             = 3;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset6) + (lWallHitRotation * new Vector3(0.0f, 0f, 0f));
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                lReachData                   = MotionReachData.Allocate();
                lReachData.StateID           = STATE_Climb_2_5m;
                lReachData.StartTime         = 0.240f;
                lReachData.EndTime           = 0.420f;
                lReachData.Power             = 4;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset7);
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                lReachData                   = MotionReachData.Allocate();
                lReachData.StateID           = STATE_ClimbToIdle;
                lReachData.StartTime         = 0.0f;
                lReachData.EndTime           = 0.5f;
                lReachData.Power             = 4;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (lWallHitRotation * _ReachOffset8);
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START, true);
            }

            // Return
            return(base.Activate(rPrevMotion));
        }
示例#5
0
        /// <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)
        {
            // Ensure we have good collision info
            if (mRaycastHitInfo.collider == null)
            {
                return(false);
            }

            //_IsGravityEnabled = false;
            //mIsGroundedExpected = false;
            mStartPosition = mActorController._Transform.position;

            // Track the object we're trying to climb and store it
            mClimbable = mRaycastHitInfo.collider.gameObject;

            // Disable actor controller processing for a short time
            mActorController.IsGravityEnabled     = false;
            mActorController.ForceGrounding       = false;
            mActorController.FixGroundPenetration = false;
            mActorController.SetGround(mClimbable.transform);

            Vector3 lClimbForward = Quaternion.AngleAxis(180, mActorController._Transform.up) * mRaycastHitInfo.normal;

            mFaceClimbableNormalAngle     = mActorController._Transform.forward.HorizontalAngleTo(lClimbForward, mActorController._Transform.up);
            mFaceClimbableNormalAngleUsed = 0f;

            // Setup the reach data and clear any current values
            ClearReachData();

            // Set the animator in motion
            //Quaternion lWallHitRotation = Quaternion.LookRotation(-mRaycastHitInfo.normal, mActorController._Transform.up);
            Quaternion lWallHitRotation = mActorController._Transform.rotation;

            MotionReachData lReachData = MotionReachData.Allocate();

            lReachData.StateID           = STATE_LegUpToIdle;
            lReachData.StartTime         = 0.0f;
            lReachData.EndTime           = 0.224f;
            lReachData.Power             = 2;
            lReachData.ReachTarget       = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset1) + (lWallHitRotation * _ReachOffset2);
            lReachData.ReachTargetGround = mActorController.State.Ground;
            mReachData.Add(lReachData);

            lReachData                   = MotionReachData.Allocate();
            lReachData.StateID           = STATE_LegUpToIdle;
            lReachData.StartTime         = 0.35f;
            lReachData.EndTime           = 0.425f;
            lReachData.Power             = 4;
            lReachData.ReachTarget       = mRaycastHitInfo.point + (lWallHitRotation * _ReachOffset3);
            lReachData.ReachTargetGround = mActorController.State.Ground;
            mReachData.Add(lReachData);

            lReachData                   = MotionReachData.Allocate();
            lReachData.StateID           = STATE_LegUpToIdle;
            lReachData.StartTime         = 0.625f;
            lReachData.EndTime           = 0.725f;
            lReachData.Power             = 4;
            lReachData.ReachTarget       = mRaycastHitInfo.point + (lWallHitRotation * _ReachOffset4);
            lReachData.ReachTargetGround = mActorController.State.Ground;
            mReachData.Add(lReachData);

            mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START, true);

            // Return
            return(base.Activate(rPrevMotion));
        }
示例#6
0
        /// <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)
        {
            // Ensure we have good collision info
            if (mRaycastHitInfo.collider == null)
            {
                return(false);
            }

            mIsExitTriggered = false;
            mStartPosition   = mActorController._Transform.position;

            // Track the object we're trying to climb and store it
            mClimbable = mRaycastHitInfo.collider.gameObject;

            // Disable actor controller processing for a short time
            mActorController.IsGravityEnabled     = false;
            mActorController.ForceGrounding       = false;
            mActorController.FixGroundPenetration = false;
            mActorController.SetGround(mClimbable.transform);

            // Set the animator in motion
            mDefaultToRun = false;
            if (_AllowRunningVault && rPrevMotion is IWalkRunMotion)
            {
                mDefaultToRun = ((IWalkRunMotion)rPrevMotion).IsRunActive;
            }
            //else if (rPrevMotion is WalkRunPivot)
            //{
            //    mDefaultToRun = ((WalkRunPivot)rPrevMotion).IsRunActive;
            //}
            //else if (rPrevMotion is WalkRunStrafe)
            //{
            //    mDefaultToRun = ((WalkRunStrafe)rPrevMotion).IsRunActive;
            //}
            //else if (rPrevMotion is WalkRunRotate)
            //{
            //    mDefaultToRun = ((WalkRunRotate)rPrevMotion).IsRunActive;
            //}

            // Setup the reach data and clear any current values
            ClearReachData();

            if (mDefaultToRun)
            {
                //Quaternion lWallHitRotation = Quaternion.LookRotation(-mRaycastHitInfo.normal, mActorController._Transform.up);
                Quaternion lWallHitRotation = mActorController._Transform.rotation;

                MotionReachData lReachData = MotionReachData.Allocate();
                lReachData.StateID           = STATE_RunVault_1m;
                lReachData.StartTime         = 0.0f;
                lReachData.EndTime           = 0.25f;
                lReachData.Power             = 3;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (mActorController._Transform.rotation * (_ReachOffset1 + new Vector3(0f, 0.3f, -0.5f))) + (lWallHitRotation * _ReachOffset2);
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START_RUN, true);
            }
            else
            {
                //Quaternion lWallHitRotation = Quaternion.LookRotation(-mRaycastHitInfo.normal, mActorController._Transform.up);
                Quaternion lWallHitRotation = mActorController._Transform.rotation;

                MotionReachData lReachData = MotionReachData.Allocate();
                lReachData.StateID           = STATE_WalkVault_1m;
                lReachData.StartTime         = 0.0f;
                lReachData.EndTime           = 0.25f;
                lReachData.Power             = 3;
                lReachData.ReachTarget       = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset1) + (lWallHitRotation * _ReachOffset2);
                lReachData.ReachTargetGround = mActorController.State.Ground;
                mReachData.Add(lReachData);

                mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START, true);
            }

            // Return
            return(base.Activate(rPrevMotion));
        }