If I understand correctly, the nodes in a NavMesh are the vertices of the mesh and the connections are the edges of the triangles. So, using a GUO or similar, I think I can set the penalties tags and walkability of the nodes/verts, correct?
Can I set the same for the triangle and/or it’s edges, similar to Unity’s navmesh area costs?
I guess a more general question is - can edges/connections be assigned penalties or walkability?
Hi
Edge costs can be modified, however currently this is only possible through code.
One option is something like this:
using UnityEngine;
using Pathfinding;
public class MyGUO : GraphUpdateObject {
public override void Apply (GraphNode node) {
var meshNode = node as TriangleMeshNode;
if (meshNode == null) return;
for (int i = 0; i < meshNode.connections.Length; i++) {
var conn = meshNode.connections[i];
conn.cost *= 2;
meshNode.connections[i] = conn;
}
}
}
which you can use like
public void Start () {
MyGUO guo = new MyGUO();
guo.bounds = new Bounds(Vector3.zero, Vector3.one*10);
AstarPath.active.UpdateGraphs(guo);
}
This will double the cost of all connections for the nodes inside that bounding box.
Excellent, that’ll work! Thank you.
Hmm, helpful, but not exactly what I want - is there a way to assign a penalty for crossing a triangle?
- (edit) ah - if I think I am missing an important concept - the nodes are the triangles themselves, not the vertices of the triangles.