Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Grab Obi Rope with Playmaker & VR
I've searched the forum with no luck with anyone being able to grab the middle of an obi rope with Playmaker or with VR.  I've found scripts (ObiContactGrabber.cs) to grab any particle automatically using Grab & Release functions, but this can't exactly be used well with Playmaker without some additional modifications and I am not a programmer.  While I understand Obi Rope isn't designed with Playmaker in mind, you can usually use Playmaker to access any publicly exposed variables, bools, methods, properties, etc. in order to get most things to work.  My largest problem is trying to detect collisions with the ObiSolver. Grabbing the ends of a rope is no problem because that doesn't rely collisions with the ObiSolver, but that doesn't allow me to climb a rope. 

While I've tried to adapt the ObiContactGrabber script to add bools to allow me to detect if a collision has been made with an ObiSolver this doesn't allow me to do a few things:
  • I need to be able to detect what solvers an ObiCollider has made contact with to allow the player to climb multiple ropes. ObiContactGrabber allows you to define only 1 solver.

So I need help or minor programming tips on how to expose some things in order for me to be able to use Playmaker. I need to be able to expose functions or variables to achieve this and would rather try to use ObiRope due to its efficiency as opposed to using a heavier rope solution from the Unity Asset Store.


So I've managed to grab the mid point of a ObiRope using the ObiContactGrabber script by simply connecting the Grab & Release functions to the "Grabbing" of an Oculus Controller. Which by default only grabs when the collision with the ObiSolver is happening. My only problem now is getting access to which ObiSolver is colliding with the ObiContactGrabber script AND a bool letting me know that the collision IS TRUE.  I can use this bool as a switch to make sure I can trigger the vertical climbing when the ObiCollider is actually in contact with the ObiSolver particles.


Managed to add a bool collision check in the "ObiSolver.cs". Allows me to check if collision is happening on the particle. I can now climb an obi rope in VR & Playmaker. Would still love to hear any thoughts on how to do this better or in a different way.

Attached Files
.cs   ObiContactGrabber.cs (Size: 5.67 KB / Downloads: 4)

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:

// 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: 9)