Hello,
I’m trying to make Node Walkable at Runtime, it turns blue on the Scene View, but with black outline. So agent can’t walk through this nodes. How can i solve this?
Image:
Code:
public class Tester : MonoBehaviour
{
private AstarPath _astar = null;
private GridGraph _graph = null;
private void Start()
{
_astar = AstarPath.active;
_graph = _astar.data.gridGraph;
}
private void Update()
{
if (Input.GetMouseButtonDown(1))
{
Vector2 mousePosition = MousePosition.WorldValue;
int x = (int)mousePosition.x;
int y = (int)mousePosition.y;
_astar.AddWorkItem(new AstarWorkItem(ctx =>
{
GraphNode node = _graph.GetNearest(mousePosition).node;
node.Walkable = true;
_graph.CalculateConnectionsForCellAndNeighbours(x, y);
}));
}
}
}