private void OnTriggerStay(Collider collision)
    {
        HealthEnemy enemy = collision.GetComponent <HealthEnemy>();

        if (enemy != null)
        {
            GetComponent <SpriteRenderer>().enabled = true;
            GetComponent <Animator>().SetTrigger("EnemyEnter");
            if (enemyList.IndexOf(enemy) == -1)
            {
                enemyList.Add(enemy);
            }
            enemy.SetLife(damage, true);
        }
        GetComponent <Animator>().SetTrigger("EnemyExit");
    }
Exemplo n.º 2
0
    private void OnTriggerEnter(Collider collision)
    {
        HealthEnemy enemy = collision.GetComponent <HealthEnemy>();

        if (enemy != null)
        {
            enemy.SetLife(damage, false);
            //Instantiate FX
            GameObject fx = (GameObject)Resources.Load("burst_tir");
            if (fx != null)
            {
                GameObject fxx = Instantiate(fx);
                fxx.transform.position = transform.position;
            }
            Destroy(gameObject);
        }
    }