How to set different RVO radius for different layers

  • A* version: 5.2.5
  • Unity version: 2022.3.55f1

Hello,
I’m developing an RTS and I’m facing a problem related to local avoidance: For the units of one team, I want the radius to be of a size to block the opposing team’s units (let’s say 2). However, with that radius, the units of the same team block each other a lot when forming up.

I have seen that RVOController can be configured by layers, and I want to know if I can configure separate layers for when units collide with their own team and with the opposing team, and configure different radius for each layer (for example, for the layer where the opposing team is, I have a radius of 2, for the layer where my team is, I have a radius of 1.2).

Is this somehow possible, even if I have to modify the script?

My units use AIPath, in 2D.

PS: I have seen some questions in the forum related to this, but they are unanswered and are old, prior to the new version, so I take this opportunity to bring it up again.

This unfortunately isn’t possible atm with local avoidance. However, you may be able to achieve similar with penalties. You can use GraphUpdateScene on your units to tag the ground they’re on as something along the lines of “NoTeamB”, and TeamB’s units have a high penalty for pathfinding through that tag. This wouldn’t allow the units to meet, however. They would avoid going that route.

Hi

If you are open to modifying scripts, you could possibly hack this together by modifying the RVOAgentBurst.cs script. The most important line is:

float combinedRadius = agentRadius + agentData.radius[otherIndex];

If you detect that the other agent is on the same team, then you could lower their radii.
You should make sure to only lower the radii, never increase it, since then the agent may have already discard the other agents earlier in the process.

1 Like

Hello

Okay, thank you both for the help. This looks promising, I’ll give it a try and I’ll come back here with the results.

1 Like