#pragma strict var agents : NavMeshAgent[]; var g:Transform; var c:Vector3 = Vector3(0,0,0) ; var t:float; var ran :float = 0; function Start () { agents = FindObjectsOfType(NavMeshAgent) as NavMeshAgent[];; t = Time.time; } function Update () { c = g.position; var X:float; var Y:float; var Z:float; if(Time.time > (t+5)){ ran = Random.Range(0,50); t = Time.time; } for(var i=1;i<=agents.Length;i++){ X = c.x + Mathf.Cos(36*i*Mathf.Deg2Rad + ran)*3; Z = c.z + Mathf.Sin(36*i*Mathf.Deg2Rad + ran)*3; Y = c.y; print(X); agents[(i-1)].SetDestination(Vector3(X,Y,Z)); } }
#pragma strict var agents : NavMeshAgent[]; var g:Transform;//英雄 var c:Vector3 = Vector3(0,0,0) ; var t:float; var ran :float = 0; var r:float = 0; function Start () { agents = FindObjectsOfType(NavMeshAgent) as NavMeshAgent[];; t = Time.time; } function Update () { c = g.position; var X:float; var Y:float; var Z:float; if(Time.time > (t+5)){ ran = Random.Range(0,50); t = Time.time; } for(var i=1;i<=agents.Length;i++){ if(agents[(i-1)].tag == "Player") r = 10; else r = 2; //var dis = Vector3.Distance(agents[(i-1)].transform.position,g.position); //if(dis> r){ agents[(i-1)].Resume(); X = c.x + Mathf.Cos(36*i*Mathf.Deg2Rad + ran)*r; Z = c.z + Mathf.Sin(36*i*Mathf.Deg2Rad + ran)*r; Y = c.y; print(X); agents[(i-1)].SetDestination(Vector3(X,Y,Z)); //}else{ // agents[(i-1)].Stop(true); //} } }