Hello!
Amazing asset, having a lot of fun playing with it so far. I’m trying to do some work to discourage the units from going up hill. At my first attempt I’ve just tried going with the most basic thing I could think of (add cost if the new node is above the previous one, remove cost if its below), however its not working. Am I at least on the right track with my thinking here? Eventually I’d like it to give score based on the angle from the previous path node (smooth downhill = low cost, steep down hill = higher cost).
Am aware this will slow things down quite a lot but am ok with this to ensure the best possible behaviour. Again, amazing asset, the local avoidance stuff makes me so happy to see.
public void UpdateG (Path path) {
#if ASTAR_NO_TRAVERSAL_COST
g = parent.g + cost;
#else
g = parent.g + cost + path.GetTraversalCost(node) + heightDiffScore(node);
#endif
}
private uint heightDiffScore(GraphNode node)
{
return (uint)(node.position.y - parent.node.position.y) * 100000;
}