Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int layerMask=~(11<<8);
- List<PathNode> wave=new List<PathNode>();
- List<PathNode> curWave=new List<PathNode>();
- wave.Add(new PathNode(source.position,0));
- do{
- curWave.Clear();
- for(int n=0;n<wave.Count;n++)
- {
- for(int m=0; m<wayPoints.Length;m++)
- {
- if(!Physics.Linecast(wave[n].WayPoint, wayPoints[m],layerMask))
- {
- int newDist=wave[n].Distance+(int)Vector3.Distance(wave[n].WayPoint, wayPoints[m]);
- if(newDist==0) continue;
- if(distances[m]==0 || distances[m]>newDist)
- {
- curWave.Add(new PathNode(wayPoints[m], newDist));
- distances[m]=newDist;
- }
- }
- }
- }
- wave.Clear();
- wave.AddRange(curWave);
- }while(wave.Count>0);
Add Comment
Please, Sign In to add comment