扇形攻击(判定)

 List list = BossManger.Instance.Bosslist;
        for (int i = 0; i < list.Count; i++)
        {
            Boss boss = list[i];
            float distance = Vector3.Distance(boss.Transform.position, _firePos.position);
            if (distance > Cfg.AttackDistance)
            {
                continue;
            }
            //求正前方与射线夹角
            float angle = Vector3.Angle(_firePos.forward, boss.Transform.position - _firePos.position);
            if (angle / 2 <= 30)
            {
                boss.Wound(_cfg.Hurt);
            }

你可能感兴趣的:(unity,脚本,游戏)