Exemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     animator          = GetComponent <Animator>();
     agent             = GetComponent <NavMeshAgent>();
     smasherController = GetComponent <SmasherController>();
     previousPosition  = transform.position;
     rb = GetComponent <Rigidbody>();
 }
Exemplo n.º 2
0
    void Die(bool explode = false)
    {
        base.Die();
        SmasherController smasherController = gameObject.GetComponentInParent <SmasherController>();

        smasherController.TurnOnRagdoll();
        SetLayerRecursively(gameObject, LayerMask.NameToLayer("DeadMonster"));
        healthBarObject.SetActive(false);
        GameObject explosionEffectInstance = null;

        if (explode)
        {
            explosionEffectInstance = Instantiate(explosionEffect, ExplosionPoint.position, ExplosionPoint.rotation);
            if (backpack)
            {
                Destroy(backpack);
            }
        }
        if (explosionEffectInstance != null)
        {
            Destroy(explosionEffectInstance, 3f);
        }
        Destroy(gameObject, 3f);
    }