Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ObiRope 3.2 Collision Position
#1
These are changes I made to determine where a Rope particle hit a Unity Collider in 3.2.
If someone has better solution please chime in!

Code:
 void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
   {
       foreach (Oni.Contact contact in e.contacts)
       {
           if (contact.distance < 0.01)
           {
               //Collider collider = solver.colliderGroup.colliders[contact.other];  **Obi 3.1
               Collider collider = ObiCollider.idToCollider[contact.other] as Collider;
               ObiSolver.ParticleInActor pa = solver.particleToActor[contact.particle];

To get ObiRope = pa.actor
To get index of Particle = pa.indexInActor,
To get collision point of Collider = collider.transform.InverseTransformPoint(contact.point));
(I use the above to Pin particle to object that was collided with)

To get ObiCollider = collider.gameObject.GetComponent<ObiCollider>();


               
*EDIT* Just noticed that niZmo's code works for 3.2 as well.  You can find a complete solution here: ObiRope 3.2+ and VRTK 3.3.0 alpha+
Reply