RVO Avoidance Layer Problems - Beta 4.3.10

When I have “Collides With” set to all layers the avoidance is working. When I switch to individual layers the avoidance does not work.

It is looking to me like the current layer calculation is incorrect.

I have AgentB that I would like AgentA to avoid.
AgentB Avoidance: Layer: 3

This does not work:
AgentA Avoidance–> Layer: 2, Collides With: Layer3

However, this does work:
AgentA Avoidance–> Layer: 2, Collides With: Layer8

So the “Collides With” does not seem to be matching up the right layers.

Changing line 456 in RVOAgentBurst.cs fixed for me.

Original:

if ((maxY < minY) | (otherIndex == agentIndex) | (((int)agentData.collidesWith[agentIndex] & (1 << (int)agentData.layer[otherIndex])) == 0)) {

Change:

if ((maxY < minY) | (otherIndex == agentIndex) | ((int)agentData.collidesWith[agentIndex] & (int)agentData.layer[otherIndex]) == 0) {

I am not sure why you are using the bit shift operation. My change seems to work, but not sure if it is affecting burst optimization.

1 Like

Hi

Do you set these layers from code or in the inspector?

Layers are only set in the inspector, nothing changes in code. As mentioned, if I just take the Left-Shift operator out of the equation then things seem to work fine. To me, it does not make sense to shift the bits left on one of the masks when comparing but maybe I am missing something.

Ah. Yes that was indeed a bug. The fix will be included in the next version.

1 Like