Advertisement
ido

Untitled

ido
May 5th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. void CastRays() {
  2.     numRays = fovAngle * quality;
  3.  
  4.     int facingAngle = fovAngle;
  5.     var dir = actor.facingVector.ToDirection ();
  6.     switch (dir) {
  7.     case Direction.Up:
  8.         break;
  9.     case Direction.Left:
  10.         facingAngle += 2*90;
  11.         break;
  12.     case Direction.Down:
  13.         facingAngle += 2*180;
  14.         break;
  15.     case Direction.Right:
  16.         facingAngle += 2*270;
  17.         break;
  18.     }
  19.  
  20.     currentAngle = facingAngle / -2;
  21.    
  22.     hits.Clear();
  23.    
  24.     for (int i = 0; i < numRays; i++) {
  25.         direction = Quaternion.AngleAxis(currentAngle, -1*transform.forward) * transform.up;
  26.         hit = new RaycastHit();
  27.        
  28.         if(Physics.Raycast(transform.position, direction, out hit, fovMaxDistance, cullingMask) == false) {
  29.             hit.point = transform.position + (direction * fovMaxDistance);
  30.         }
  31.        
  32.         hits.Add(hit);
  33.  
  34.         currentAngle += 1f / quality;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement