How to approch an obstacle with Raycast graph and RVO?

I’m working on a rts game and my current setup I the following:

  • Raycast graph
  • I use NavMeshCut for runtime constructions like buildings to update graph
  • RVO enabled for my units
  • Units and similarly RVOControllers has different attack range/agent radius.

I need some general guidance how to implement an approach logic for an “Attack building” order.

Let say my building has nav mesh cuts defined that update the nav mesh. I want to calculate the best path for a unit to approach a building and start attacking it within unit’s attack range.

Now my first approach would be to use an arbitrary picked center point for a building and calculate a crud path to this place for my unit. Then, when the unit is close to the said building within certain range, I would have to recalculate the path accounting for RVO agents and find a suitable “free” spot around the nav mesh cut within units attack range so it can actually start attacking it. This will mean I have to update initially calculated destination, because it might not necessary be the shortest point straight to the edge of mesh cut.

Example:
surround

The nav mesh cuts could be arbitrary, but for simplicity I guess I would have to assume they are all either circles or rectangles. One building can consist of multiple nav mesh cuts.

What would be the best approach to achieve such behavior? I welcome any suggestions :slight_smile: .

Hi

One approach that many games use successfully is to keep a list of attack points around each unit (e.g. 8 of them) in a circle around each object. When an attacker wants to attack some unit it will reserve on of those points so that no other unit can use it and then it will move towards that point. This will lead to a quite nice surround of the agents.

You could also try the RTS beta branch (see https://arongranberg.com/astar/download, click the ‘Show Older Versions’ button) which has some additional local avoidance code inspired very much by what Starcraft 2 does. I haven’t tested surround with it, but I think it should work relatively well.

I’m actually in the process of calculating the node outline of the building using tags and cuts, this sound similar to your suggestion with reserving points around the given object.

Thanks for the suggestions, will check the RTS branch as well, cheers!

1 Like