void TestPath() { Path p = Astar.CalculatePath(start, end, grid); foreach (Node n in p.nodes) { var mesh = n.GetComponent <MeshRenderer>(); mesh.material.color = Color.green; } }
public static void ComputePath() { if (m_start != null && m_end != null) { m_finalPath = m_astar.CalculatePath(m_start, m_end); } }
private void OnMouseEnter() { var grid = FindObjectOfType <GridSystem>(); Path p = Astar.CalculatePath(grid.gridNodes[0], this, grid); foreach (Node n in grid.gridNodes) { if (n.walkable) { n.GetComponent <MeshRenderer>().material.SetColor("_BaseColor", Color.white); } } foreach (Node n in p.nodes) { var mesh = n.GetComponent <MeshRenderer>(); mesh.material.SetColor("_BaseColor", Color.green); } //p.nodes[0].GetComponent<MeshRenderer>().material.color = Color.green; }
private void Update() { if (movingInitiatedUnit == false) { return; } Node startingNode = currentlyInitiatedUnit.GetMyGridNode(); Node destinationNode = GetMousedOverNode(); if (GetMousedOverNode() == null) { return; } //Will calculate path AND show the path in-game Path movementPath = Astar.CalculatePath(startingNode, destinationNode, generatedGrid); if (InputListener.Instance.PressedDown_Mouse_LeftClick) { OrderUnitMovement(currentlyInitiatedUnit, movementPath); } }