Advertisement
napland

how to debug draw box cast

Feb 10th, 2016
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. //box cast extents are the same as would be used in Physics.BoxCast
  2. //hitPoint is the RaycastHit.point returned from the boxcast
  3.  
  4. Vector3 upperLeft, upperRight, lowerLeft, lowerRight;
  5. upperLeft = new Vector3(
  6.     transform.position.x - 0.5f * boxCastExtents.x,
  7.     transform.position.y + 0.5f * boxCastExtents.y,
  8.     transform.position.z);
  9.  
  10. upperRight = new Vector3(
  11.     transform.position.x + 0.5f * boxCastExtents.x,
  12.     transform.position.y + 0.5f * boxCastExtents.y,
  13.     transform.position.z);
  14.  
  15. lowerLeft = new Vector3(
  16.     transform.position.x - 0.5f * boxCastExtents.x,
  17.     transform.position.y - 0.5f * boxCastExtents.y,
  18.     transform.position.z);
  19.  
  20. lowerRight = new Vector3(
  21.     transform.position.x + 0.5f * boxCastExtents.x,
  22.     transform.position.y - 0.5f * boxCastExtents.y,
  23.     transform.position.z);
  24.  
  25. Vector3 upperLeft1, upperRight1, lowerLeft1, lowerRight1;
  26. upperLeft1 = new Vector3(
  27.     hitPoint.x - 0.5f * boxCastExtents.x,
  28.     hitPoint.y + 0.5f * boxCastExtents.y,
  29.     hitPoint.z);
  30.  
  31. upperRight1 = new Vector3(
  32.     hitPoint.x + 0.5f * boxCastExtents.x,
  33.     hitPoint.y + 0.5f * boxCastExtents.y,
  34.     hitPoint.z);
  35.  
  36. lowerLeft1 = new Vector3(
  37.     hitPoint.x - 0.5f * boxCastExtents.x,
  38.     hitPoint.y - 0.5f * boxCastExtents.y,
  39.     hitPoint.z);
  40.  
  41. lowerRight1 = new Vector3(
  42.     hitPoint.x + 0.5f * boxCastExtents.x,
  43.     hitPoint.y - 0.5f * boxCastExtents.y,
  44.     hitPoint.z);
  45.  
  46. Debug.DrawLine(upperLeft, upperLeft + 100f * transform.forward, color, 1.25f * Time.deltaTime);
  47. Debug.DrawLine(upperRight, upperRight + 100f* transform.forward, color, 1.25f * Time.deltaTime);
  48. Debug.DrawLine(lowerLeft, lowerLeft + 100f * transform.forward, color, 1.25f * Time.deltaTime);
  49. Debug.DrawLine(lowerRight, lowerRight + 100f * transform.forward, color, 1.25f * Time.deltaTime);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement