Ejemplo n.º 1
0
 void WeapCol()
 {
     //碰撞监测
     Collider[] hits = Physics.OverlapSphere(hitPoint.transform.position, radius, ignoreLayers);
     foreach (Collider c in hits)
     {
         if (c.isTrigger)
         {
             continue;
         }
         bh       = c.GetComponent <Collider>().gameObject.GetComponent <BossHealth>();
         collided = true;
         if (collided)
         {
             Instantiate(attackEffectPrefab, hitPoint.transform.position, hitPoint.transform.rotation);
             bh.BossTakeBlood(damageCount);
         }
     }
 }
Ejemplo n.º 2
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 <BossHealth>();          //获得当前碰撞对象的生命脚本
            collided     = true;
            if (collided)
            {
                Instantiate(damageEffect, transform.position, transform.rotation);
                attackTarget.BossTakeBlood(damageCount);
            }
        }
    }