コード例 #1
0
    //-------------------------------------------------------------------------------------------------
    // Method: EnableRagdoll
    // Desc:   Turns off the flame particle effect and hit collider if this is the flamer enemy
    //         disables AI components like nav agent and StateController.cs
    //         turns all collider rigidbodies to be non-kinematic and disable the main capsule col
    //         Start the body disposal after 5 seconds (should be enough time for the body to lie still
    //--------------------------------------------------------------------------------------------------
    public void EnableRagdoll()
    {
        // Conditional logic to disable flame attack of flamer enemy when he is ragdolled:
        if (_enemyAnimationScript._leftHandFlamer || _enemyAnimationScript._rightHandFlamer)
        {
            _enemyAnimationScript.ToggleFlameAttackOff(2);
        }
        _anim.enabled = false;

        _stateController.enabled      = false;
        _navAgent.enabled             = false;
        _enemyAnimationScript.enabled = false;


        foreach (Rigidbody rb in _rigidbodies)
        {
            rb.isKinematic = false;
        }
        _mainCol.enabled = false;
        // If this is a flamer enemy we want to disable all his particle effects upon ragdolling:
        if (GetComponent <StateControllerRanged>())
        {
            foreach (ParticleSystem ps in GetComponentsInChildren <ParticleSystem>())
            {
                ps.Stop();
            }
        }
        Invoke("EmitParticlesFromMesh", 5.0f);
    }