Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections.Generic;
- using Pathfinding;
- public class ClosestPointDebugger : MonoBehaviour {
- public void OnDrawGizmos () {
- if (AstarPath.active != null) {
- var info = AstarPath.active.GetNearest(transform.position, NNConstraint.Default);
- if (info.node != null) {
- Gizmos.color = Color.green;
- Gizmos.DrawSphere(transform.position, 0.05F);
- Gizmos.color = Color.blue;
- Gizmos.DrawLine((Vector3)transform.position, (Vector3)info.node.position);
- Gizmos.color = Color.cyan;
- Gizmos.DrawLine(transform.position, info.position);
- } else {
- Gizmos.color = Color.red;
- Gizmos.DrawSphere(transform.position, 0.05F);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement