Exemplo n.º 1
0
    public GameObject damageEffect;  //伤害特效

    void Update()
    {
        //碰撞监测
        Collider[] hits = Physics.OverlapSphere(transform.position, radius, ignoreLayers);
        foreach (Collider c in hits)
        {
            if (c.isTrigger)
            {
                continue;
            }
            attackTarget = c.GetComponent <Collider>().gameObject.GetComponent <EnemyHealth>();          //获得当前碰撞对象的生命脚本
            collided     = true;
            if (collided)
            {
                Instantiate(damageEffect, transform.position, transform.rotation);
                attackTarget.EnemyTakeBlood(damageCount);
            }
        }
    }