目录
43、机器人对敌方的检测和移动逻辑
更新PlayerBot.cs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using Random = UnityEngine.Random;
public class PlayerBot : Player
{
……
IEnumerator DetectPlayers()
{
yield return new WaitForEndOfFrame();
while (true)
{
inRange.Clear();
Collider[] cols = Physics.OverlapSphere(transform.position, range, LayerMask.GetMask("Player"));
for (int i = 0; i < cols.Length; ++i)
{
Player p = cols[i].gameObject.GetComponent<Player>();
if (p.teamIndex != teamIndex && !inRange.Contai