Guest User

Untitled

a guest
Jul 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. int layerMask=~(11<<8);
  2. List<PathNode> wave=new List<PathNode>();
  3. List<PathNode> curWave=new List<PathNode>();
  4. wave.Add(new PathNode(source.position,0));
  5. do{
  6. curWave.Clear();
  7. for(int n=0;n<wave.Count;n++)
  8. {
  9. for(int m=0; m<wayPoints.Length;m++)
  10. {
  11. if(!Physics.Linecast(wave[n].WayPoint, wayPoints[m],layerMask))
  12. {
  13. int newDist=wave[n].Distance+(int)Vector3.Distance(wave[n].WayPoint, wayPoints[m]);
  14. if(newDist==0) continue;
  15. if(distances[m]==0 || distances[m]>newDist)
  16. {
  17. curWave.Add(new PathNode(wayPoints[m], newDist));
  18. distances[m]=newDist;
  19. }
  20. }
  21. }
  22. }
  23. wave.Clear();
  24. wave.AddRange(curWave);
  25.  
  26. }while(wave.Count>0);
Add Comment
Please, Sign In to add comment