The goal this week was to make the planner output a different plan by modifying graph traversal costs; this cost modification is based on spatial relationship to a constraint object. In order to test the cost function without worrying about the A* heuristics, we always estimate the distance to the goal to be
h(
x) = 0 (thus
reducing A* to Dijkstra's).
The results are illustrated in the following images. By multiplying the Euclidean distance by a multiplier (equal to from the graph edge midpoint to the distance to the constraint), we "discourage" the search from going away from the constraint object.
 |
| A plan to go straight to the goal. |
 |
A plan that is weighted to go near the long object at the bottom.
(Those crazy bubbles are a debugging tool: they scale with the value of g at that point in the search.) |
|
I have noticed one important problem with this simple approach, however: once we want to leave the constraint object and go toward the goal object, the search becomes very slow--since the costs discourage the search from going away from the constraint object, it suddenly gets very slow. I tried defining the multiplier based on distance to both goal and constraint, but I haven't yet found anything that actually works without almost completely ignoring the constraint.
It should also be noted that we are using a very approximate system right now: we simply multiply cost based on distance to the center of the constraint object. In the future, we want it to work based on the distance to the nearest point "on" the object (really, on a collider annotation).
Aside: As it turns out, reducing the accuracy of the mesh (Navigation -> Bake -> Advanced -> Width/Height Inaccuracy %) makes the NavMesh much cleaner around sharp corners (and quicker to bake) while subdividing it much less. For now, this seems to be a more reasonable way to generate meshes.
 |
| Inaccuracy 1% (left) and 10% (right) |
 |
| Unfortunately, the mesh is still messy at 10%. |
To do:
- Get annotations working (by testing against a short vertical ray?)
- Use annotations to compute multiplier based on distance to closest point on annotation. (Don't use ClosestPointOnBounds--it operates on AABB.)
- More robust constraint system (with until)?
- Put text on the bubbles so that we actually know what the g values are.
- Make an argument that the cost multiplier actually makes sense.
- Note that it is an increase in cost per distance, rather than a cost per node as with an addend.
- Revisit the list of constraints and model them in this system.
- Try a cost weighting system that reduces weights perpendicular to the constraint--this is specific to "near"/"along" constraints, though.
No comments:
Post a Comment