Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. using Pathfinding;
  4.  
  5. public class ClosestPointDebugger : MonoBehaviour {
  6.     public void OnDrawGizmos () {
  7.         if (AstarPath.active != null) {
  8.             var info = AstarPath.active.GetNearest(transform.position, NNConstraint.Default);
  9.  
  10.             if (info.node != null) {
  11.                 Gizmos.color = Color.green;
  12.                 Gizmos.DrawSphere(transform.position, 0.05F);
  13.  
  14.                 Gizmos.color = Color.blue;
  15.                 Gizmos.DrawLine((Vector3)transform.position, (Vector3)info.node.position);
  16.  
  17.                 Gizmos.color = Color.cyan;
  18.                 Gizmos.DrawLine(transform.position, info.position);
  19.             } else {
  20.                 Gizmos.color = Color.red;
  21.                 Gizmos.DrawSphere(transform.position, 0.05F);
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement