Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Grab Obi Rope with Playmaker & VR
#2
Hi!

If you need to use multiple solvers instead of just one, you can subscribe to multiple solvers' OnCollision event instead of just one. Minor modifications are needed in the example ObiContactGrabber.cs script:

- Declare ObiSolver[] (solver)instead of a ObiSolver.
- Declare a Dictionary<ObiSolver,ObiSolver.ObiCollisionEventArgs> collisionEvents to map each solver to its collision event.
- Add a ObiSolver field in the GrabbedParticle inner class, so each particle solver which solver it belongs to.
- Iterate over solvers/collisionEvents where needed, instead of accessing a single solver/collisionEvent.

A boolean flag indicating if there's anything grabbed can be added by simply checking whether the list of grabbed actors contains at least 1 actor. Find the modified ObiContactGrabber.cs script attached this post.

If you'd rather know if there's any collision, regardless of the grabber actually grabbing an actor, just subscribe to the OnCollision event and turn a bool value true if there's any non-speculative contact in the list:

Code:
// declare a collision bool at the top of your class:
bool collision;

void Solver_OnCollision (object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
   // reset the bool to false. We will make it true if we find any collision.
   collision = false;

    foreach (Oni.Contact contact in e.contacts)
    {
        // this one is an actual collision:
        if (contact.distance < 0.01)
        {
                collision = true; return;
        }
    }
}

No need to modify any core components, such as ObiSolver. Note that Obi assumes not only programming skills, but also familiarity with basic physics simulation concepts (timestep, forces, impulses, masses, etc). These aren't explained in detail anywhere in the documentation, so if you're uncomfortable with these using Obi will present a steep learning curve.


Attached Files
.cs   ObiContactGrabber.cs (Size: 5.98 KB / Downloads: 16)
Reply


Messages In This Thread
RE: Grab Obi Rope with Playmaker & VR - by josemendez - 05-10-2020, 07:54 AM