I am using Solver_OnCollision on CollisionEventHandler to discover colliding OBI bodies.
contact.bodyB provides the correct index = 2
However, contact.bodyA provides an arbitrary index of 352, which is well beyond the count of world.colliderHandles (there are 3).
Can you please advise? Code attached.
void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
// just iterate over all contacts in the current frame:
foreach (Oni.Contact contact in e.contacts)
{
// if this one is an actual collision:
if (contact.distance < 0.001f)
{
ObiColliderBase HitCollider = world.colliderHandles[contact.bodyB].owner;
if (HitCollider != null && HitCollider.gameObject.tag != "Tether")
{
Debug.Log("Body count = " + world.colliderHandles.Count); // returns 3
Debug.Log("bodyA = " + contact.bodyA); // returns 352
Debug.Log("bodyB = " + contact.bodyB); // returns 2
if (world.colliderHandles[contact.bodyB].owner != null)
{
Debug.Log(HitCollider.gameObject.name);
}
}
}
}
}
contact.bodyB provides the correct index = 2
However, contact.bodyA provides an arbitrary index of 352, which is well beyond the count of world.colliderHandles (there are 3).
Can you please advise? Code attached.
void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
// just iterate over all contacts in the current frame:
foreach (Oni.Contact contact in e.contacts)
{
// if this one is an actual collision:
if (contact.distance < 0.001f)
{
ObiColliderBase HitCollider = world.colliderHandles[contact.bodyB].owner;
if (HitCollider != null && HitCollider.gameObject.tag != "Tether")
{
Debug.Log("Body count = " + world.colliderHandles.Count); // returns 3
Debug.Log("bodyA = " + contact.bodyA); // returns 352
Debug.Log("bodyB = " + contact.bodyB); // returns 2
if (world.colliderHandles[contact.bodyB].owner != null)
{
Debug.Log(HitCollider.gameObject.name);
}
}
}
}
}