Hello,
Our upcoming game uses Obi 6.5.4. It is co-op game with two players that are connected via tether and also both players have controllable whip, all three objects are ObiRopes.
Both players have ObiColliders with PinConstraint for both ends of the tether.
On the scene we have some attachable objects with ObiCollider that are dynamically spawned for limited time, with Enable / Disable calls.
From time to time we observe index out of bounds in PinConstraintsBatchJob.Execute.
Locally we added validation of colliderIndex wrt shapes array bounds.
if (colliderIndex < 0 || colliderIndex >= shapes.Length)
{
UnityEngine.Debug.LogError($"Collider index {colliderIndex} is out of range of '{shapes.Length}' Length at {i}");
continue;
}
After fixing couple of issues on our side due to attaching whip to invalid objects (colliderIndex == -1) we started (rarely) observe of colliderIndex being beyond shapes.Length.
After extensive tracking down we found that invalidation of colliders in ObiColliderWorld.DestroyCollider may change collider index that is used in ObiPinConstraintsBatch and possibly in other places.
This situation happens for us for ObiColliders in players and their ids are near the colliderHandles.Count
Invalidation of another collider will take collider at the end of colliderHandles and insert it to the invalidated collider place changing its index.
int index = handle.index;
int lastIndex = colliderHandles.Count - 1;
colliderHandles.Swap(index, lastIndex);
colliderHandles[index].index = index;
ObiPinConstraintBatch will still use old collider id that will more than shapes.Length in PinConstraintsBatchJob
For what I see in the sources of ObiRope 7.1 the problem can also happen there.
I'd appreciate ideas how to address the issue easy and cleanly.
Our upcoming game uses Obi 6.5.4. It is co-op game with two players that are connected via tether and also both players have controllable whip, all three objects are ObiRopes.
Both players have ObiColliders with PinConstraint for both ends of the tether.
On the scene we have some attachable objects with ObiCollider that are dynamically spawned for limited time, with Enable / Disable calls.
From time to time we observe index out of bounds in PinConstraintsBatchJob.Execute.
Locally we added validation of colliderIndex wrt shapes array bounds.
if (colliderIndex < 0 || colliderIndex >= shapes.Length)
{
UnityEngine.Debug.LogError($"Collider index {colliderIndex} is out of range of '{shapes.Length}' Length at {i}");
continue;
}
After fixing couple of issues on our side due to attaching whip to invalid objects (colliderIndex == -1) we started (rarely) observe of colliderIndex being beyond shapes.Length.
After extensive tracking down we found that invalidation of colliders in ObiColliderWorld.DestroyCollider may change collider index that is used in ObiPinConstraintsBatch and possibly in other places.
This situation happens for us for ObiColliders in players and their ids are near the colliderHandles.Count
Invalidation of another collider will take collider at the end of colliderHandles and insert it to the invalidated collider place changing its index.
int index = handle.index;
int lastIndex = colliderHandles.Count - 1;
colliderHandles.Swap(index, lastIndex);
colliderHandles[index].index = index;
ObiPinConstraintBatch will still use old collider id that will more than shapes.Length in PinConstraintsBatchJob
For what I see in the sources of ObiRope 7.1 the problem can also happen there.
I'd appreciate ideas how to address the issue easy and cleanly.


