/*public void Awake() { enabled = false; }*/ public static NavmeshEdge Create(NavmeshVertex vertex1, NavmeshVertex vertex2) { GameObject edgeGO = new GameObject("Navmesh Edge"); edgeGO.AddComponent("NavmeshEdge"); edgeGO.tag = "NavmeshEdge"; NavmeshEdge edge = (NavmeshEdge)edgeGO.GetComponent("NavmeshEdge"); edge.vertices[0] = vertex1; edge.vertices[1] = vertex2; edge.ResetPosition(); edge.ResetCollider(); return edge; }
public NavmeshEdge AddActiveEdge(NavmeshVertex neighbour) { NavmeshEdge edgeToActivate = null; foreach (NavmeshEdge edge in edges){ if (edge != null && edge.GetOtherVertex(this) == neighbour){ edgeToActivate = edge; } } if (edgeToActivate == null){ edgeToActivate = NavmeshEdge.Create(this, neighbour); AddEdge(edgeToActivate); neighbour.AddEdge(edgeToActivate); } edgeToActivate.SetActivated(true); return edgeToActivate; }
public NavmeshVertex GetOtherVertex(NavmeshVertex vertex) { foreach (NavmeshVertex otherVertex in vertices){ if (vertex != otherVertex){ return otherVertex; } } Debug.LogError("Other NavmeshVertex not found in NavmeshEdge!"); return null; }