Help bodyA on Solver_OnCollision yielding arbitrary index - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Help bodyA on Solver_OnCollision yielding arbitrary index (/thread-3892.html) |
bodyA on Solver_OnCollision yielding arbitrary index - michendo - 27-05-2023 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); } } } } } RE: bodyA on Solver_OnCollision yielding arbitrary index - josemendez - 27-05-2023 (27-05-2023, 06:09 AM)michendo Wrote: I am using Solver_OnCollision on CollisionEventHandler to discover colliding OBI bodies. Hi! Obi only deals with particles and Unity’s collider components. Particles and colliders are collectively referred to as “bodies”. In the case of particle-collider contacts, bodyA is a simplex index, bodyB is a collider index. In case of particle-particle contacts, both bodyA and bodyB are simplex indices. In no case bodyA is a collider index. See the documentation for details: http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html By default (unless your cloth uses surface collisions) cloth simplices are made of one particle each. bodyA = 352 and bodyB = 2 means particle #352 in a cloth actor is colliding against collider #2. Let me know if you need further help, Kind regards |