Exemplo n.º 1
0
    public void DecapitatePart()
    {
        if (_partRenderer != null && _part != null && !_decapitated)
        {
            _decapitated = true;
            _part.gameObject.SetActive(true);
            _part.transform.parent = null;

            _partRenderer.SetActive(false);

            if (_attack != null)
            {
                _attack.enabled = false;
            }

            if (_instantKill)
            {
                AIStateMachine stateMachine = GetComponentInParent <AIStateMachine>();
                if (stateMachine != null)
                {
                    Health parentHealth = stateMachine.GetComponentInParent <Health>();
                    if (parentHealth != null)
                    {
                        parentHealth.TakeDamage(10, transform.position);
                    }
                }
            }
        }
    }