Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Assigning Obi Handle in Editor
#2
(04-07-2019, 10:25 PM)Necka Wrote: Hello, 

I am sorry if this question has already been answered, I did a search, but I gave up after the 4th page, maybe my search keyword wasn't good enough.

The question is simple: Is it possible to assign a handle manually?

Example: I select a particle and "create handle" this will create a new handle in the hierarchy.

But while doing tests, I re-initialize my rope multiple times and each time I have to create a new handle (and delete the previous one). Because I can't find a way to assign a particle to a handle manually.

I'm probably blind but I have no idea where this handle reference is made. It doesn't appear in Pin Constrains, neither on the handle component itself, and I can't find it anywhere in the different rope components.

Also that is something I wondered in the case I want two ropes to have one particle attached to the same handle. Is it possible (I know I can do it in other ways, such as pin constraint, but that handle system is so easy and simple to manage.. also I don't have to worry about collision problems with this system)

Thanks by advance

Hi there,

First off, handles and pin constraints work in different ways and give different results, so they're often not interchangeable. Depending on what you need to do, you want to use one or   the other.

- Pin constraints establish a two-way connection between the rope and the object it is pinned to. This means that the rope will exert forces on the object, and vice versa. This allows you to hang objects from the rope, ie objects that can pull the rope and be pulled by it.

- Handles are simply a convenient way of "fixing" (freezing) a group of particles, and setting their positions so that they match a transform. This means the particles in the handle have their dynamics deactivated (not affected by gravity, external forces or constraints) and are simply moved by means of directly setting their position. Because of this, particles will simply move to where the handle tells them, will ignore any forces or constraints (that's why collisions do not affect them in any way) and will not extern any force on the handle or any object in the handle's hierarchy.

To assign a handle at runtime (i assume this is what you mean by "manually"), you simply  create a new GameObject, add the ObiHandle component to it. Handles have a very simple API: you can add particle indices to them, or remove particle indices from them. That's pretty much it:
http://obi.virtualmethodstudio.com/api.html

For instance, to create a handle that fixes the position of the first two particles in a cloth:

Code:
// Create a new game object and add the handle component:
GameObject obj = new GameObject("Obi Handle");
ObiParticleHandle handle = obj.AddComponent<ObiParticleHandle>();

// Add the first two particles to it:
handle.AddParticle(i, actor.GetParticlePosition(0),Quaternion.identity,actor.invMasses[0],0);
handle.AddParticle(i, actor.GetParticlePosition(1),Quaternion.identity,actor.invMasses[1],0);

Note that after re-initializing a rope, all the particles are created from scratch, so existing handles lose their references. You must re-create the handles after that.
Reply


Messages In This Thread
Assigning Obi Handle in Editor - by Necka - 04-07-2019, 10:25 PM
RE: Assigning Obi Handle in Editor - by josemendez - 05-07-2019, 08:23 AM
RE: Assigning Obi Handle in Editor - by Necka - 05-07-2019, 01:23 PM