Exemplo n.º 1
0
    /// <summary>
    /// Function for switching between ragdoll-modes
    /// </summary>
    public void ToggleRagdollMode(RagdollMode mode)
    {
        switch (mode)
        {
        case RagdollMode.Animated:
        {
            if (playerRigidbody.isKinematic == true)
            {
                RamecanMixer.BeginStateTransition("default");
                playerRigidbody.isKinematic = false;
            }
        }
        break;

        case RagdollMode.Ragdoll:
        {
            if (!Dead && !Reviving)
            {
                RamecanMixer.BeginStateTransition("dead");
                playerRigidbody.isKinematic = true;
                animator.SetTrigger("Die");
            }
        }
        break;
        }
    }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     state         = EnemyStates.PATROL;
     anim          = GetComponent <Animator>();
     agent         = GetComponent <NavMeshAgent>();
     ragdoll       = GetComponent <RagdollMode>();
     speedModified = false;
 }
        private void SwitchMode(RagdollMode mode)
        {
            _mode = mode;

            switch (_mode)
            {
            case RagdollMode.Mode1:
                _statusMessage = "Mode: Animated ragdoll with dynamic bodies";

                // Make rigid bodies dynamic. The rigid bodies are affected by forces
                // and constraints.
                foreach (var body in _ragdoll.Bodies)
                {
                    if (body != null)
                    {
                        body.MotionType = MotionType.Dynamic;
                    }
                }

                _ragdoll.DisableMotors();
                _ragdoll.DisableJoints();
                _ragdoll.DisableLimits();
                break;

            case RagdollMode.Mode2:
                _statusMessage = "Mode: Animated ragdoll with kinematic bodies";

                // Make rigid bodies kinematic. The rigid bodies can push dynamic objects,
                // but they are themselves not affected by forces.
                foreach (var body in _ragdoll.Bodies)
                {
                    if (body != null)
                    {
                        body.MotionType = MotionType.Kinematic;
                    }
                }

                // Set all motors to velocity motors. The velocity motors drive the rigid
                // bodies to absolute target positions.
                foreach (var motor in _ragdoll.Motors)
                {
                    if (motor != null)
                    {
                        motor.Mode = RagdollMotorMode.Velocity;
                    }
                }

                _ragdoll.EnableMotors();
                _ragdoll.DisableJoints();
                _ragdoll.DisableLimits();
                break;

            case RagdollMode.Mode3:
                _statusMessage = "Mode: Passive ragdoll (damping only)";

                // Make rigid bodies dynamic. The rigid bodies are affected by forces
                // and constraints.
                foreach (var body in _ragdoll.Bodies)
                {
                    if (body != null)
                    {
                        body.MotionType = MotionType.Dynamic;
                    }
                }

                // Set all motors to constraint motors that only use damping. This adds
                // a damping effect to all ragdoll limbs, which slows down motions and
                // increases stability.
                foreach (var motor in _ragdoll.Motors)
                {
                    if (motor != null)
                    {
                        motor.Mode = RagdollMotorMode.Constraint;
                        motor.ConstraintDamping = 5;
                        motor.ConstraintSpring  = 0;
                    }
                }

                _ragdoll.EnableMotors();
                _ragdoll.EnableJoints();
                _ragdoll.EnableLimits();
                break;

            case RagdollMode.Mode4:
                _statusMessage = "Mode: Active ragdoll with motors";

                // Make rigid bodies dynamic. The rigid bodies are affected by forces
                // and constraints.
                foreach (var body in _ragdoll.Bodies)
                {
                    if (body != null)
                    {
                        body.MotionType = MotionType.Dynamic;
                    }
                }

                // Set all motors to constraint motors. The motors control the joints
                // of the ragdoll.
                foreach (var motor in _ragdoll.Motors)
                {
                    if (motor != null)
                    {
                        motor.Mode = RagdollMotorMode.Constraint;
                        motor.ConstraintDamping = 1000000;
                        motor.ConstraintSpring  = 10000000;
                    }
                }

                _ragdoll.EnableMotors();
                _ragdoll.EnableJoints();

                // It is recommended to disable limits in this mode. The limits may conflict
                // with the goals of the constraint motors. This could lead to instabilities.
                _ragdoll.DisableLimits();
                break;
            }
        }
Exemplo n.º 4
0
    private void SwitchMode(RagdollMode mode)
    {
      _mode = mode;

      switch (_mode)
      {
        case RagdollMode.Mode1:
          _statusMessage = "Mode: Animated ragdoll with dynamic bodies";

          // Make rigid bodies dynamic. The rigid bodies are affected by forces
          // and constraints.
          foreach (var body in _ragdoll.Bodies)
            if (body != null)
              body.MotionType = MotionType.Dynamic;

          _ragdoll.DisableMotors();
          _ragdoll.DisableJoints();
          _ragdoll.DisableLimits();
          break;

        case RagdollMode.Mode2:
          _statusMessage = "Mode: Animated ragdoll with kinematic bodies";

          // Make rigid bodies kinematic. The rigid bodies can push dynamic objects, 
          // but they are themselves not affected by forces.
          foreach (var body in _ragdoll.Bodies)
            if (body != null)
              body.MotionType = MotionType.Kinematic;

          // Set all motors to velocity motors. The velocity motors drive the rigid
          // bodies to absolute target positions.
          foreach (var motor in _ragdoll.Motors)
            if (motor != null)
              motor.Mode = RagdollMotorMode.Velocity;

          _ragdoll.EnableMotors();
          _ragdoll.DisableJoints();
          _ragdoll.DisableLimits();
          break;

        case RagdollMode.Mode3:
          _statusMessage = "Mode: Passive ragdoll (damping only)";

          // Make rigid bodies dynamic. The rigid bodies are affected by forces
          // and constraints.
          foreach (var body in _ragdoll.Bodies)
            if (body != null)
              body.MotionType = MotionType.Dynamic;

          // Set all motors to constraint motors that only use damping. This adds 
          // a damping effect to all ragdoll limbs, which slows down motions and
          // increases stability.
          foreach (var motor in _ragdoll.Motors)
          {
            if (motor != null)
            {
              motor.Mode = RagdollMotorMode.Constraint;
              motor.ConstraintDamping = 5;
              motor.ConstraintSpring = 0;
            }
          }

          _ragdoll.EnableMotors();
          _ragdoll.EnableJoints();
          _ragdoll.EnableLimits();
          break;

        case RagdollMode.Mode4:
          _statusMessage = "Mode: Active ragdoll with motors";

          // Make rigid bodies dynamic. The rigid bodies are affected by forces
          // and constraints.
          foreach (var body in _ragdoll.Bodies)
            if (body != null)
              body.MotionType = MotionType.Dynamic;

          // Set all motors to constraint motors. The motors control the joints
          // of the ragdoll.
          foreach (var motor in _ragdoll.Motors)
          {
            if (motor != null)
            {
              motor.Mode = RagdollMotorMode.Constraint;
              motor.ConstraintDamping = 1000000;
              motor.ConstraintSpring = 10000000;
            }
          }

          _ragdoll.EnableMotors();
          _ragdoll.EnableJoints();

          // It is recommended to disable limits in this mode. The limits may conflict
          // with the goals of the constraint motors. This could lead to instabilities.
          _ragdoll.DisableLimits();
          break;
      }
    }