Advertisement
lemansky

Untitled

Apr 14th, 2024
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1.  void OnDrawGizmos()
  2.     {
  3.         Vector3 origin = transform.position;
  4.         Vector3 direction = transform.forward * range;
  5.  
  6.         if (Physics.Raycast(origin, direction, out hit, range))
  7.         {
  8.             Gizmos.color = Color.green;
  9.             Gizmos.DrawLine(origin, hit.point);
  10.             Gizmos.DrawSphere(hit.point + Vector3.up* 0.1f, 0.5f);
  11.         }
  12.         else
  13.         {
  14.             Gizmos.color = Color.red;
  15.             Gizmos.DrawLine(origin, origin + direction);
  16.             Gizmos.DrawSphere(origin + direction, 0.5f);
  17.         }
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement