Пример #1
0
        private void RunCycleUpdate(MovementProperty movement)
        {
            if (movement.m_cycleTimer < movement.m_cycleSpeed)
            {
                movement.m_cycleTimer += Time.fixedDeltaTime;
            }
            else
            {
                movement.m_cycleTimer = 0f;

                int pose = (int)movement.m_leftLegPose;
                movement.m_leftLegPose = (Pose)(++pose <= 3 ? pose : 0);

                pose = (int)movement.m_rightLegPose;
                movement.m_rightLegPose = (Pose)(++pose <= 3 ? pose : 0);

                pose = (int)movement.m_leftArmPose;
                movement.m_leftArmPose = (Pose)(++pose <= 3 ? pose : 0);

                pose = (int)movement.m_rightArmPose;
                movement.m_rightArmPose = (Pose)(++pose <= 3 ? pose : 0);
            }
        }
Пример #2
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);
        }