I require that every 2 seconds the grid is updated with the camera facing orientation + box so that particular agents can avoid moving in front of the player.
I have tried to do this with tags and GraphUpdateScene, however
- calling apply multiple times seems to be additive and does not remove the previously modified tags
- this method will take over the entire tag system as you can only have one tag per node
Is there a better way to do this / how can i undo a tag change from a graphupdatescene apply without resetting the entire graph.
For that kind of very quickly changing penalty, I would recommend using an ITraversalProvider. See Utilities for turn-based games - A* Pathfinding Project
Thanks, couple more questions.
- How frequent is GetTraversalCost called (will the above math and concurrent code be an issue?)
- What is the best way to apply this to an AIPath (with or without modifying the AIPath class)?
Edit: At most there will be two assigned ambushers in most case, so maximum two AIPaths running that TraversalModifier
It will be called for every node that is searched. Depending on the graph, this may easily be in the thousands. Note that if you use multithreading, this will be called from a separate thread. The math is probably fine, but I would recommend that you store the Camera’s position/rotation in fields on the ITraversalProvider instead of getting them every time (since the camera might move while the path calculation is being done).
Currently there is no way to inject this without either:
- or sublcassing the AIPath script and overriding the SearchPath method.
Works great with what you have suggested. Very powerful feature.
Now ambushers try to avoid in front of the player and come from behind.