private void EnforceConnection() { if (LinkEstablished && LinkActive) { PointA.ConnectTo(PointB, NavNodeConnection.NavConnectionType.Standard); if (Bidirectional) { PointB.ConnectTo(PointA, NavNodeConnection.NavConnectionType.Standard); } } }
void EstablishLink() { _lastPointAPos = transform.TransformPoint(PointAPos); _lastPointBPos = transform.TransformPoint(PointBPos); _lastBidirectional = Bidirectional; PointA = NavMesh2D.ClosestNodeTo(transform.TransformPoint(PointAPos)); PointB = NavMesh2D.ClosestNodeTo(transform.TransformPoint(PointBPos)); if (PointA == null || PointB == null) { PointA = NavMesh2D.ActualClosestNodeTo(transform.TransformPoint(PointAPos)); PointB = NavMesh2D.ActualClosestNodeTo(transform.TransformPoint(PointBPos)); if (PointA == null || PointB == null) { return; } } if (Bidirectional && PointA.IsConnectedTo(PointB) && PointB.IsConnectedTo(PointA)) { PointA = null; PointB = null; return; } if (!Bidirectional && PointA.IsConnectedTo(PointB)) { PointA = null; PointB = null; return; } PointA.ConnectTo(PointB, NavNodeConnection.NavConnectionType.Standard); if (Bidirectional) { PointB.ConnectTo(PointA, NavNodeConnection.NavConnectionType.Standard); } }