예제 #1
0
        private void Stand(MoveSystemNeededProperty entity)
        {
            var body    = entity.m_bodyProperty;
            var control = entity.m_controlProperty;
            var state   = entity.m_stateProperty;

            ApplyForceUtils.AlignToVector(body[BodyPart.Head], body[BodyPart.Head].BodyTransform.forward,
                                          control.m_lookDirection, 0.1f, 20f * control.m_applyForce, true);
            ApplyForceUtils.AlignToVector(body[BodyPart.Head], body[BodyPart.Head].BodyTransform.up,
                                          Vector3.up, 0.1f, 20f * control.m_applyForce, true);

            ApplyForceUtils.AlignToVector(body[BodyPart.Torso], body[BodyPart.Torso].BodyTransform.forward,
                                          control.m_direction, 0.1f, 40f * control.m_applyForce, true);
            ApplyForceUtils.AlignToVector(body[BodyPart.Torso], body[BodyPart.Torso].BodyTransform.up,
                                          Vector3.up, 0.1f, 40f * control.m_applyForce, true);

            ApplyForceUtils.AlignToVector(body[BodyPart.Hip], body[BodyPart.Hip].BodyTransform.forward,
                                          control.m_direction, 0.1f, 40f * control.m_applyForce, true);
            ApplyForceUtils.AlignToVector(body[BodyPart.Hip], body[BodyPart.Hip].BodyTransform.up,
                                          Vector3.up, 0.1f, 30f * control.m_applyForce, true);

            ApplyForceUtils.AlignToVector(body[BodyPart.LeftLeg], body[BodyPart.LeftLeg].BodyTransform.up,
                                          body[BodyPart.Hip].BodyTransform.up, 0.1f, 30f * control.m_applyForce);
            ApplyForceUtils.AlignToVector(body[BodyPart.RightLeg], body[BodyPart.RightLeg].BodyTransform.up,
                                          body[BodyPart.Hip].BodyTransform.up, 0.1f, 30f * control.m_applyForce);

            body[BodyPart.Torso].BodyRigid.AddForce(new Vector3(0, 4, 0) * control.m_applyForce, ForceMode.VelocityChange);
            body[BodyPart.Hip].BodyRigid.AddForce(new Vector3(0, -3.5f, 0) * control.m_applyForce, ForceMode.VelocityChange);

            body[BodyPart.Anchor].BodyRigid.angularVelocity = Vector3.zero;
        }
        private void Fall()
        {
            ApplyForceUtils.AlignToVector(_body[BodyPart.Head], _body[BodyPart.Head].BodyTransform.up,
                                          Vector3.up, 0.1f, 20f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.Head], _body[BodyPart.Head].BodyTransform.forward,
                                          _control.m_lookDirection, 0.1f, 20f);

            ApplyForceUtils.AlignToVector(_body[BodyPart.Torso], _body[BodyPart.Torso].BodyTransform.up,
                                          Vector3.up, 0.1f, 20f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.Torso], _body[BodyPart.Torso].BodyTransform.forward,
                                          _control.m_direction + Vector3.down, 0.1f, 10f);

            ApplyForceUtils.AlignToVector(_body[BodyPart.Hip], _body[BodyPart.Hip].BodyTransform.forward,
                                          _control.m_direction + Vector3.up, 0.1f, 20f);

            ApplyForceUtils.AlignToVector(_body[BodyPart.LeftLeg], _body[BodyPart.LeftLeg].BodyTransform.forward,
                                          _body[BodyPart.Hip].BodyTransform.forward + Vector3.down * 0.3f, 0.1f, 20f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.RightLeg], _body[BodyPart.RightLeg].BodyTransform.forward,
                                          _body[BodyPart.Hip].BodyTransform.forward + Vector3.down * 0.3f, 0.1f, 20f);

            if (InputUtils.ValidMove(new Vector2(_control.m_rawDirection.x, _control.m_rawDirection.z)))
            {
                _body[BodyPart.Hip].BodyRigid.AddForce(
                    (_control.m_direction + Vector3.up) * 0.2f, ForceMode.VelocityChange);
            }

            _body[BodyPart.Anchor].BodyRigid.angularVelocity = Vector3.zero;
        }
예제 #3
0
        private void Fall(MoveSystemNeededProperty entity)
        {
            var body    = entity.m_bodyProperty;
            var control = entity.m_controlProperty;

            ApplyForceUtils.AlignToVector(body[BodyPart.Head], body[BodyPart.Head].BodyTransform.forward,
                                          control.m_lookDirection, 0.1f, 20f);

            ApplyForceUtils.AlignToVector(body[BodyPart.Torso], body[BodyPart.Torso].BodyTransform.up,
                                          Vector3.up, 0.1f, 40f);
            ApplyForceUtils.AlignToVector(body[BodyPart.Torso], body[BodyPart.Torso].BodyTransform.forward,
                                          control.m_direction, 0.1f, 40f);

            ApplyForceUtils.AlignToVector(body[BodyPart.Hip], body[BodyPart.Hip].BodyTransform.up,
                                          Vector3.up, 0.1f, 20f);
            ApplyForceUtils.AlignToVector(body[BodyPart.Hip], body[BodyPart.Hip].BodyTransform.forward,
                                          control.m_direction, 0.1f, 20f);

            ApplyForceUtils.AlignToVector(body[BodyPart.LeftLeg], body[BodyPart.LeftLeg].BodyTransform.up,
                                          body[BodyPart.Hip].BodyTransform.up, 0.1f, 20f);
            ApplyForceUtils.AlignToVector(body[BodyPart.RightLeg], body[BodyPart.RightLeg].BodyTransform.up,
                                          body[BodyPart.Hip].BodyTransform.up, 0.1f, 20f);

            if (InputUtils.ValidMove(new Vector2(control.m_rawDirection.x, control.m_rawDirection.z)))
            {
                body[BodyPart.Torso].BodyRigid.AddForce(control.m_direction * 0.2f, ForceMode.VelocityChange);
            }
        }
        private void Stand()
        {
            ApplyForceUtils.AlignToVector(_body[BodyPart.Head], _body[BodyPart.Head].BodyTransform.forward,
                                          _control.m_lookDirection, 0.1f, 20f * _control.m_applyForce, true);
            ApplyForceUtils.AlignToVector(_body[BodyPart.Head], _body[BodyPart.Head].BodyTransform.up,
                                          Vector3.up, 0.1f, 10f * _control.m_applyForce, true);

            ApplyForceUtils.AlignToVector(_body[BodyPart.Torso], _body[BodyPart.Torso].BodyTransform.forward,
                                          _control.m_direction, 0.1f, 10f * _control.m_applyForce, true);
            ApplyForceUtils.AlignToVector(_body[BodyPart.Torso], _body[BodyPart.Torso].BodyTransform.up,
                                          Vector3.up, 0.1f, 20f * _control.m_applyForce, true);

            ApplyForceUtils.AlignToVector(_body[BodyPart.Hip], _body[BodyPart.Hip].BodyTransform.forward,
                                          _control.m_direction, 0.1f, 10f * _control.m_applyForce, true);
            ApplyForceUtils.AlignToVector(_body[BodyPart.Hip], _body[BodyPart.Hip].BodyTransform.up,
                                          Vector3.up, 0.1f, 20f * _control.m_applyForce, true);

            ApplyForceUtils.AlignToVector(_body[BodyPart.LeftLeg], _body[BodyPart.LeftLeg].BodyTransform.up,
                                          _body[BodyPart.Hip].BodyTransform.up, 0.1f, 30f * _control.m_applyForce);
            ApplyForceUtils.AlignToVector(_body[BodyPart.RightLeg], _body[BodyPart.RightLeg].BodyTransform.up,
                                          _body[BodyPart.Hip].BodyTransform.up, 0.1f, 30f * _control.m_applyForce);

            ApplyForceUtils.Straighten(_body[BodyPart.Torso], _body[BodyPart.Hip],
                                       Vector3.up, 4 * _control.m_applyForce, ForceMode.VelocityChange);
        }
        private void RunCycleMainBody()
        {
            _body[BodyPart.Torso].BodyRigid.AddForce(
                (RunVecForce10 + 0.6f * _control.m_direction) * _control.m_applyForce,
                ForceMode.VelocityChange);
            _body[BodyPart.Hip].BodyRigid.AddForce(
                (-RunVecForce5 + 0.5f * _control.m_direction) * _control.m_applyForce,
                ForceMode.VelocityChange);
            _body[BodyPart.Anchor].BodyRigid.AddForce(
                (-RunVecForce5 + 0.6f * _control.m_direction) * _control.m_applyForce,
                ForceMode.VelocityChange);

            ApplyForceUtils.AlignToVector(_body[BodyPart.Head], _body[BodyPart.Head].BodyTransform.forward,
                                          _control.m_lookDirection, 0.1f, 5f * _control.m_applyForce);
            ApplyForceUtils.AlignToVector(_body[BodyPart.Head], _body[BodyPart.Head].BodyTransform.up,
                                          Vector3.up, 0.1f, 5f * _control.m_applyForce);

            ApplyForceUtils.AlignToVector(_body[BodyPart.Torso], _body[BodyPart.Torso].BodyTransform.forward,
                                          _control.m_direction + Vector3.down, 0.1f, 10f * _control.m_applyForce);
            ApplyForceUtils.AlignToVector(_body[BodyPart.Torso], _body[BodyPart.Torso].BodyTransform.up,
                                          Vector3.up, 0.1f, 10f * _control.m_applyForce);

            ApplyForceUtils.AlignToVector(_body[BodyPart.Hip], _body[BodyPart.Hip].BodyTransform.forward,
                                          _control.m_direction, 0.1f, 10f * _control.m_applyForce);
            ApplyForceUtils.AlignToVector(_body[BodyPart.Hip], _body[BodyPart.Hip].BodyTransform.up,
                                          Vector3.up, 0.1f, 10f * _control.m_applyForce);
        }
        private void RunCyclePoseLeg(Side side, Pose pose)
        {
            Transform hip = _body[BodyPart.Hip].BodyTransform;

            Transform sideLeg    = null;
            Transform unsideKnee = null;

            Rigidbody sideLegRig   = null;
            Rigidbody sideKneeRig  = null;
            Rigidbody unsideLegRig = null;

            switch (side)
            {
            case Side.Left:
                sideLeg      = _body[BodyPart.LeftLeg].BodyTransform;
                unsideKnee   = _body[BodyPart.RightKnee].BodyTransform;
                sideLegRig   = _body[BodyPart.LeftLeg].BodyRigid;
                unsideLegRig = _body[BodyPart.RightLeg].BodyRigid;
                sideKneeRig  = _body[BodyPart.LeftKnee].BodyRigid;
                break;

            case Side.Right:
                sideLeg      = _body[BodyPart.RightLeg].BodyTransform;
                unsideKnee   = _body[BodyPart.LeftKnee].BodyTransform;
                sideLegRig   = _body[BodyPart.RightLeg].BodyRigid;
                unsideLegRig = _body[BodyPart.LeftLeg].BodyRigid;
                sideKneeRig  = _body[BodyPart.RightKnee].BodyRigid;
                break;
            }

            switch (pose)
            {
            case Pose.Bent:
                ApplyForceUtils.AlignToVector(sideLegRig, -sideLeg.up, _control.m_direction, 0.1f, 4f * _control.m_applyForce);
                break;

            case Pose.Forward:
                ApplyForceUtils.AlignToVector(sideLegRig, -sideLeg.up, _control.m_direction - hip.up / 2, 0.1f, 4f * _control.m_applyForce);
                sideLegRig.AddForce(-_control.m_direction * 2f, ForceMode.VelocityChange);
                sideKneeRig.AddForce(_control.m_direction * 2f, ForceMode.VelocityChange);
                break;

            case Pose.Straight:
                ApplyForceUtils.AlignToVector(sideLegRig, sideLeg.up, Vector3.up, 0.1f, 4f * _control.m_applyForce);
                sideLegRig.AddForce(hip.up * 2f * _control.m_applyForce);
                sideKneeRig.AddForce(-hip.up * 2f * _control.m_applyForce);
                break;

            case Pose.Behind:
                ApplyForceUtils.AlignToVector(sideLegRig, sideLeg.up, _control.m_direction * 2f, 0.1f, 4f * _control.m_applyForce);
                break;
            }
        }
예제 #7
0
    /// <summary>
    /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
    /// </summary>
    private void FixedUpdate()
    {
        if (!m_attached)
        {
            Vector3 dir = m_targetItem.transform.rotation * m_targetItem.m_grabTarget -
                          transform.position + m_targetItem.transform.position;

            ApplyForceUtils.AlignToVector(
                _rig, transform.forward, dir.normalized, 0.1f, 2f);
            ApplyForceUtils.AlignToVector(
                _rig, transform.up, Vector3.up, 0.1f, 20f);
        }
    }
예제 #8
0
        private void Pick()
        {
            Vector3 leftArmDir = (_body[BodyPart.Torso].BodyTransform.right * 2 +
                                  _body[BodyPart.Torso].BodyTransform.forward).normalized;
            Vector3 leftDelt = (_body[BodyPart.Torso].BodyTransform.right -
                                _body[BodyPart.Torso].BodyTransform.forward).normalized * 0.75f;

            ApplyForceUtils.AlignToVector(_body[BodyPart.LeftArm],
                                          _body[BodyPart.LeftArm].BodyTransform.up, Vector3.up, 1f, 10f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.LeftElbow],
                                          _body[BodyPart.LeftElbow].BodyTransform.up, Vector3.up, 1f, 10f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.LeftHand],
                                          _body[BodyPart.LeftHand].BodyTransform.up, Vector3.up, 1f, 5f);

            ApplyForceUtils.AlignToVector(_body[BodyPart.RightArm],
                                          _body[BodyPart.RightArm].BodyTransform.up, Vector3.up, 1f, 10f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.RightElbow],
                                          _body[BodyPart.RightElbow].BodyTransform.up, Vector3.up, 1f, 10f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.RightHand],
                                          _body[BodyPart.RightHand].BodyTransform.up, Vector3.up, 1f, 5f);

            ApplyForceUtils.AlignToVector(_body[BodyPart.LeftArm],
                                          _body[BodyPart.LeftArm].BodyTransform.forward, leftArmDir, 1f, 1f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.RightArm],
                                          _body[BodyPart.RightArm].BodyTransform.forward, -leftArmDir, 1f, 1f);

            ApplyForceUtils.AlignToVector(_body[BodyPart.LeftElbow],
                                          _body[BodyPart.LeftElbow].BodyTransform.forward, leftArmDir + leftDelt, 1f, 1f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.RightElbow],
                                          _body[BodyPart.RightElbow].BodyTransform.forward, -leftArmDir - leftDelt, 1f, 1f);

            ApplyForceUtils.AlignToVector(_body[BodyPart.LeftHand],
                                          _body[BodyPart.LeftHand].BodyTransform.forward, leftArmDir + 2 * leftDelt, 1f, 1f);
            ApplyForceUtils.AlignToVector(_body[BodyPart.RightHand],
                                          _body[BodyPart.RightHand].BodyTransform.forward, -leftArmDir - 2 * leftDelt, 1f, 1f);

            _body[BodyPart.LeftHand].BodyRigid.AddForce(
                Vector3.up + leftArmDir + 2 * leftDelt, ForceMode.Force);
            _body[BodyPart.RightHand].BodyRigid.AddForce(
                Vector3.up - leftArmDir - 2 * leftDelt, ForceMode.Force);
        }
예제 #9
0
        private void RunCycleMainBody(ControlProperty control, MovementProperty movement, BodyProperty body)
        {
            if (control.m_run)
            {
                movement.m_runForce = Mathf.Clamp(movement.m_runForce + Time.fixedDeltaTime, 0f, 1f);
            }
            else
            {
                movement.m_runForce = Mathf.Clamp(movement.m_runForce - Time.fixedDeltaTime, 0f, 1f);
            }

            body[BodyPart.Torso].BodyRigid.AddForce(
                (MovementProperty.RunVecForce10 + 0.3f * control.m_direction * movement.m_runForce) * control.m_applyForce,
                ForceMode.VelocityChange);
            body[BodyPart.Hip].BodyRigid.AddForce(
                (-MovementProperty.RunVecForce5 + 0.3f * control.m_direction * movement.m_runForce) * control.m_applyForce,
                ForceMode.VelocityChange);
            body[BodyPart.Anchor].BodyRigid.AddForce(-MovementProperty.RunVecForce5 * control.m_applyForce, ForceMode.VelocityChange);

            body[BodyPart.Anchor].BodyRigid.AddForce(
                control.m_direction * control.m_applyForce, ForceMode.VelocityChange);

            ApplyForceUtils.AlignToVector(body[BodyPart.Head], body[BodyPart.Head].BodyTransform.forward,
                                          control.m_lookDirection, 0.1f, 5f * control.m_applyForce);
            ApplyForceUtils.AlignToVector(body[BodyPart.Head], body[BodyPart.Head].BodyTransform.up,
                                          Vector3.up, 0.1f, 5f * control.m_applyForce);

            ApplyForceUtils.AlignToVector(body[BodyPart.Torso], body[BodyPart.Torso].BodyTransform.forward,
                                          control.m_direction + Vector3.down, 0.1f, 10f * control.m_applyForce);
            ApplyForceUtils.AlignToVector(body[BodyPart.Torso], body[BodyPart.Torso].BodyTransform.up,
                                          Vector3.up, 0.1f, 10f * control.m_applyForce);

            ApplyForceUtils.AlignToVector(body[BodyPart.Hip], body[BodyPart.Hip].BodyTransform.forward,
                                          control.m_direction, 0.1f, 10f * control.m_applyForce);
            ApplyForceUtils.AlignToVector(body[BodyPart.Hip], body[BodyPart.Hip].BodyTransform.up,
                                          Vector3.up, 0.1f, 10f * control.m_applyForce);
        }
예제 #10
0
        private void Jump(MoveSystemNeededProperty entity)
        {
            var state   = entity.m_stateProperty;
            var control = entity.m_controlProperty;
            var body    = entity.m_bodyProperty;

            if (state.m_state != state.m_lastState)
            {
                float runFactor = control.m_run ? 0.4f : 0.2f;

                if (control.m_jump)
                {
                    Vector3 hipVelocity = body[BodyPart.Hip].BodyRigid.velocity;
                    if (hipVelocity.y < 2f)
                    {
                        body[BodyPart.Torso].BodyRigid.AddForce(control.m_direction * runFactor, ForceMode.VelocityChange);
                        body[BodyPart.Hip].BodyRigid.AddForce(control.m_direction * runFactor, ForceMode.VelocityChange);

                        float torsoY = body[BodyPart.Torso].BodyTransform.position.y;
                        float hipY   = body[BodyPart.Hip].BodyTransform.position.y;

                        if (torsoY > hipY)
                        {
                            Vector3 jumpForce = Vector3.up * 30f;
                            body[BodyPart.Torso].BodyRigid.AddForce(jumpForce, ForceMode.VelocityChange);
                            body[BodyPart.Hip].BodyRigid.AddForce(jumpForce, ForceMode.VelocityChange);
                        }
                        else
                        {
                            Vector3 jumpForce = Vector3.up * 15f;
                            body[BodyPart.Torso].BodyRigid.AddForce(jumpForce, ForceMode.VelocityChange);
                            body[BodyPart.Hip].BodyRigid.AddForce(jumpForce, ForceMode.VelocityChange);
                        }
                    }
                }
                control.m_jump = false;
            }

            if (InputUtils.ValidMove(new Vector2(control.m_rawDirection.x, control.m_rawDirection.z)))
            {
                body[BodyPart.Torso].BodyRigid.AddForce(Vector3.up * 2f, ForceMode.VelocityChange);
                body[BodyPart.Hip].BodyRigid.AddForce(Vector3.up * 2f, ForceMode.VelocityChange);

                ApplyForceUtils.AlignToVector(
                    body[BodyPart.Torso], body[BodyPart.Torso].BodyTransform.up,
                    Vector3.up, 0.1f, 10f);
                ApplyForceUtils.AlignToVector(
                    body[BodyPart.Torso], body[BodyPart.Torso].BodyTransform.forward,
                    control.m_direction + Vector3.down, 0.1f, 10f);
                ApplyForceUtils.AlignToVector(
                    body[BodyPart.Hip], body[BodyPart.Hip].BodyTransform.up,
                    Vector3.up, 0.1f, 10f);
                ApplyForceUtils.AlignToVector(
                    body[BodyPart.Hip], body[BodyPart.Hip].BodyTransform.forward,
                    control.m_direction + Vector3.up, 0.1f, 10f);

                ApplyForceUtils.AlignToVector(
                    body[BodyPart.LeftArm], body[BodyPart.LeftArm].BodyTransform.up,
                    body[BodyPart.Torso].BodyTransform.right + body[BodyPart.Torso].BodyTransform.forward,
                    0.1f, 4f);
                ApplyForceUtils.AlignToVector(
                    body[BodyPart.LeftElbow], body[BodyPart.LeftArm].BodyTransform.up,
                    body[BodyPart.Torso].BodyTransform.right - body[BodyPart.Torso].BodyTransform.forward,
                    0.1f, 4f);

                ApplyForceUtils.AlignToVector(
                    body[BodyPart.RightArm], body[BodyPart.RightArm].BodyTransform.up, -body[BodyPart.Torso].BodyTransform.right + body[BodyPart.Torso].BodyTransform.forward,
                    0.1f, 4f);
                ApplyForceUtils.AlignToVector(
                    body[BodyPart.RightElbow], body[BodyPart.RightElbow].BodyTransform.up, -body[BodyPart.Torso].BodyTransform.right - body[BodyPart.Torso].BodyTransform.forward,
                    0.1f, 4f);

                ApplyForceUtils.AlignToVector(
                    body[BodyPart.LeftLeg], body[BodyPart.LeftLeg].BodyTransform.up,
                    body[BodyPart.Hip].BodyTransform.up - body[BodyPart.Hip].BodyTransform.forward,
                    0.1f, 4f);
                ApplyForceUtils.AlignToVector(
                    body[BodyPart.RightLeg], body[BodyPart.RightLeg].BodyTransform.up,
                    body[BodyPart.Hip].BodyTransform.up - body[BodyPart.Hip].BodyTransform.forward,
                    0.1f, 4f);
            }
        }
예제 #11
0
        private void RunCyclePoseLeg(Side side, Pose pose, ControlProperty control, BodyProperty body)
        {
            Transform hip = body[BodyPart.Hip].BodyTransform;

            Transform sideLeg    = null;
            Transform unsideKnee = null;

            Rigidbody sideLegRig   = null;
            Rigidbody sideKneeRig  = null;
            Rigidbody unsideLegRig = null;

            switch (side)
            {
            case Side.Left:
                sideLeg      = body[BodyPart.LeftLeg].BodyTransform;
                unsideKnee   = body[BodyPart.RightKnee].BodyTransform;
                sideLegRig   = body[BodyPart.LeftLeg].BodyRigid;
                unsideLegRig = body[BodyPart.RightLeg].BodyRigid;
                sideKneeRig  = body[BodyPart.LeftKnee].BodyRigid;
                break;

            case Side.Right:
                sideLeg      = body[BodyPart.RightLeg].BodyTransform;
                unsideKnee   = body[BodyPart.LeftKnee].BodyTransform;
                sideLegRig   = body[BodyPart.RightLeg].BodyRigid;
                unsideLegRig = body[BodyPart.LeftLeg].BodyRigid;
                sideKneeRig  = body[BodyPart.RightKnee].BodyRigid;
                break;
            }

            switch (pose)
            {
            case Pose.Bent:
                ApplyForceUtils.AlignToVector(sideLegRig, -sideLeg.up, control.m_direction, 0.1f, 4f * control.m_applyForce);
                break;

            case Pose.Forward:
                if (control.m_run)
                {
                    ApplyForceUtils.AlignToVector(sideLegRig, -sideLeg.up, control.m_direction, 0.1f, 4f * control.m_applyForce);
                    sideLegRig.AddForce(-control.m_direction * 2f * control.m_applyForce);
                    sideKneeRig.AddForce(control.m_direction * 2f * control.m_applyForce);
                }
                else
                {
                    ApplyForceUtils.AlignToVector(sideLegRig, -sideLeg.up, control.m_direction - hip.up / 2, 0.1f, 4f * control.m_applyForce);
                    sideLegRig.AddForce(-control.m_direction * 2f, ForceMode.VelocityChange);
                    sideKneeRig.AddForce(control.m_direction * 2f, ForceMode.VelocityChange);
                }
                break;

            case Pose.Straight:
                ApplyForceUtils.AlignToVector(sideLegRig, sideLeg.up, Vector3.up, 0.1f, 4f * control.m_applyForce);
                sideLegRig.AddForce(hip.up * 2f * control.m_applyForce);
                sideKneeRig.AddForce(-hip.up * 2f * control.m_applyForce);
                break;

            case Pose.Behind:
                if (control.m_run)
                {
                    ApplyForceUtils.AlignToVector(sideLegRig, sideLeg.up, control.m_direction * 2f, 0.1f, 4f * control.m_applyForce);
                    body[BodyPart.Hip].BodyRigid.AddForce(MovementProperty.RunVecForce2 * control.m_applyForce, ForceMode.VelocityChange);
                    body[BodyPart.Anchor].BodyRigid.AddForce(-MovementProperty.RunVecForce2 * control.m_applyForce, ForceMode.VelocityChange);
                    sideKneeRig.AddForce(-body[BodyPart.Hip].BodyTransform.forward, ForceMode.VelocityChange);
                }
                else
                {
                    ApplyForceUtils.AlignToVector(sideLegRig, sideLeg.up, control.m_direction * 2f, 0.1f, 4f * control.m_applyForce);
                }
                break;
            }
        }
        private void Jump()
        {
            if (_state.m_state != _state.m_lastState)
            {
                if (_control.m_jump)
                {
                    Vector3 hipVelocity = _body[BodyPart.Hip].BodyRigid.velocity;
                    if (hipVelocity.y < 2f)
                    {
                        _body[BodyPart.Torso].BodyRigid.AddForce(_control.m_direction * 0.5f, ForceMode.VelocityChange);
                        _body[BodyPart.Hip].BodyRigid.AddForce(_control.m_direction * 0.5f, ForceMode.VelocityChange);

                        float torsoY = _body[BodyPart.Torso].BodyTransform.position.y;
                        float hipY   = _body[BodyPart.Hip].BodyTransform.position.y;

                        if (torsoY > hipY)
                        {
                            Vector3 jumpForce = Vector3.up * 20f;
                            _body[BodyPart.Torso].BodyRigid.AddForce(jumpForce, ForceMode.VelocityChange);
                            _body[BodyPart.Hip].BodyRigid.AddForce(jumpForce, ForceMode.VelocityChange);
                        }
                        else
                        {
                            Vector3 jumpForce = Vector3.up * 10f;
                            _body[BodyPart.Torso].BodyRigid.AddForce(jumpForce, ForceMode.VelocityChange);
                            _body[BodyPart.Hip].BodyRigid.AddForce(jumpForce, ForceMode.VelocityChange);
                        }
                    }
                }
                _control.m_jump = false;
            }

            if (InputUtils.ValidMove(new Vector2(_control.m_rawDirection.x, _control.m_rawDirection.z)))
            {
                _body[BodyPart.Torso].BodyRigid.AddForce(Vector3.up * 2f, ForceMode.VelocityChange);
                _body[BodyPart.Hip].BodyRigid.AddForce(Vector3.up * 2f, ForceMode.VelocityChange);

                ApplyForceUtils.AlignToVector(
                    _body[BodyPart.Torso], _body[BodyPart.Torso].BodyTransform.forward,
                    _control.m_direction + Vector3.down, 0.1f, 10f);
                ApplyForceUtils.AlignToVector(
                    _body[BodyPart.Hip], _body[BodyPart.Hip].BodyTransform.forward,
                    _control.m_direction + Vector3.up, 0.1f, 10f);

                ApplyForceUtils.AlignToVector(
                    _body[BodyPart.LeftArm], _body[BodyPart.LeftArm].BodyTransform.up,
                    _body[BodyPart.Torso].BodyTransform.right + _body[BodyPart.Torso].BodyTransform.forward,
                    0.1f, 4f);
                ApplyForceUtils.AlignToVector(
                    _body[BodyPart.LeftElbow], _body[BodyPart.LeftArm].BodyTransform.up,
                    _body[BodyPart.Torso].BodyTransform.right - _body[BodyPart.Torso].BodyTransform.forward,
                    0.1f, 4f);

                ApplyForceUtils.AlignToVector(
                    _body[BodyPart.RightArm], _body[BodyPart.RightArm].BodyTransform.up, -_body[BodyPart.Torso].BodyTransform.right + _body[BodyPart.Torso].BodyTransform.forward,
                    0.1f, 4f);
                ApplyForceUtils.AlignToVector(
                    _body[BodyPart.RightElbow], _body[BodyPart.RightElbow].BodyTransform.up, -_body[BodyPart.Torso].BodyTransform.right - _body[BodyPart.Torso].BodyTransform.forward,
                    0.1f, 4f);

                ApplyForceUtils.AlignToVector(
                    _body[BodyPart.LeftLeg], _body[BodyPart.LeftLeg].BodyTransform.up,
                    _body[BodyPart.Hip].BodyTransform.up - _body[BodyPart.Hip].BodyTransform.forward,
                    0.1f, 4f);
                ApplyForceUtils.AlignToVector(
                    _body[BodyPart.RightLeg], _body[BodyPart.RightLeg].BodyTransform.up,
                    _body[BodyPart.Hip].BodyTransform.up - _body[BodyPart.Hip].BodyTransform.forward,
                    0.1f, 4f);
            }
        }