예제 #1
0
    //Returns the nearest node's position from a Vector3 point, will never return null (Vector3.zero), except for when there are no calculated grids.
    public Vector3 GetNearestNodePositionUnclamped(Vector3 pos)
    {
        Int3 p = AstarPath.ToLocalUnclamped(pos);

        if (p != new Int3(-1, -1, -1))
        {
            return(AstarPath.GetNode(p).vectorPos);
        }
        else
        {
            return(Vector3.zero);
        }
    }
예제 #2
0
    //Returns the nearest node from a Vector3 point, this function can return null if the point is not contained inside any grids bounds.
    public Node GetNearestNode(Vector3 pos)
    {
        Int3 p = AstarPath.ToLocal(pos);

        if (p != new Int3(-1, -1, -1))
        {
            return(AstarPath.GetNode(p));
        }
        else
        {
            return(null);
        }
    }