private void BuildAlertLocationPath(VRPatrolAgent pg) { alertLocationPath = null; PathSingle p1 = GameObject.Find("PATHNET").GetComponent <PathNet>().PathList[0]; PathSingle p2 = GameObject.Find("PATHNET").GetComponent <PathNet>().PathList[1]; Transform player = GameObject.Find("SoldierBluePlayer").transform; int id = -1; float d = 999; float dd = Vector3.Distance(p1.start, player.position); if (dd < d) { d = dd; id = 0; } dd = Vector3.Distance(p1.end, player.position); if (dd < d) { d = dd; id = 1; } dd = Vector3.Distance(p2.start, player.position); if (dd < d) { d = dd; id = 2; } dd = Vector3.Distance(p2.end, player.position); if (dd < d) { d = dd; id = 3; } Vector3 p = (p1.start + p1.end + p2.start + p2.end) / 4; switch (id) { case 0: p = p1.start; break; case 1: p = p1.end; break; case 2: p = p2.start; break; case 3: p = p2.end; break; } pg.lookTarget = player; pg.agent.SetDestination(p); pg.agent.speed = .5f; pg.loco.Play(5); pg._alertMode = false; }
void Awake() { _pathlist = new List<PathSingle>(); int childCount = transform.childCount; for (int i = 0; i < childCount; i++) { PathSingle ps = new PathSingle(); ps.start = transform.GetChild(i).FindChild("TargetA").position; ps.end = transform.GetChild(i).FindChild("TargetB").position; ps.pathIndex = i; _pathlist.Add(ps); } }
void Awake() { _pathlist = new List <PathSingle>(); int childCount = transform.childCount; for (int i = 0; i < childCount; i++) { PathSingle ps = new PathSingle(); ps.start = transform.GetChild(i).FindChild("TargetA").position; ps.end = transform.GetChild(i).FindChild("TargetB").position; ps.pathIndex = i; _pathlist.Add(ps); } }