I have an annoying problem with OverlapSphere. Every time I run this code, the waypoint “store” as neighbor itself. So If I set a communication between three waypoints, the script cuts out one neighbor to set the waypoint itself as neighbor. It’s pretty weird… here is the code:
var neighb:Collider[];
var mask : LayerMask = 1<<8;
var sphereDistance:int = 1;
private var breakWhile:int;
var countDown:int;
function Awake () {
while (neighb.Length < 3 && breakWhile <10){
neighb = Physics.OverlapSphere(transform.position,sphereDistance, mask);
sphereDistance += 10;
breakWhile++;
}
}
function Update () {
Debug.Log(this.name +" " + neighb.Length + " " + sphereDistance );
}