Penalty for particular agents in front of camera

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

  1. calling apply multiple times seems to be additive and does not remove the previously modified tags
  2. this method will take over the entire tag system as you can only have one tag per node

Question:

Is there a better way to do this / how can i undo a tag change from a graphupdatescene apply without resetting the entire graph.

Cheers

Hi

For that kind of very quickly changing penalty, I would recommend using an ITraversalProvider. See Utilities for turn-based games - A* Pathfinding Project

1 Like

Thanks, couple more questions.

  1. How frequent is GetTraversalCost called (will the above math and concurrent code be an issue?)
  2. 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:

  1. Using ai.SetPath
  2. or sublcassing the AIPath script and overriding the SearchPath method.
1 Like

Works great with what you have suggested. Very powerful feature.
Thanks!

Now ambushers try to avoid in front of the player and come from behind.

2 Likes