Add Constraint problems - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Add Constraint problems (/thread-2588.html) |
Add Constraint problems - datzme - 22-11-2020 I have some problems with constraints. This is what im trying to do: https://i.imgur.com/uMuY596.gif This is the code var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>; pinConstraints.Clear(); Vector3 hit = rope.transform.InverseTransformPoint(contact.point); // this didnt work at all. var batch = new ObiPinConstraintsBatch(); // cheating with the pos, dont know how to get the correct position. batch.AddConstraint(rope.solverIndices[contact.particle], boxCollider, new Vector3(-0.5f,-0.25f,0), Quaternion.identity,0,0,float.PositiveInfinity); batch.activeConstraintCount = 1; boxCollider.Phase = 1; pinConstraints.AddBatch(batch); rope.SetConstraintsDirty(Oni.ConstraintType.Pin); : what im trying to do is to make it stick to the box smooth, and then i want to be able to drag the box around and rope follow smoothly. I also tried to use the Grab script, it looks good, but it will go crazy kinda fast: https://i.imgur.com/zogiZZZ.gif RE: Add Constraint problems - josemendez - 23-11-2020 As stated in the manual, the solver performs all simulation in local space. All contact, particle, and constraint values are expressed in the solver's local space. This: (22-11-2020, 07:01 PM)datzme Wrote: Vector3 hit = rope.transform.InverseTransformPoint(contact.point); // this didnt work at all. Will transform a world space position to the rope's local frame. Neither the origin or the destination vector spaces are correct. It should be: Quote:Vector3 hit = boxCollider.transform.InverseTransformPoint(rope.solver.transform.TransformPoint(contact.point)); // solver to collider space. (22-11-2020, 07:01 PM)datzme Wrote: I also tried to use the Grab script, it looks good, but it will go crazy kinda fast: I'll assume the box is a rigidbody: your issue is that you're attaching the rope too close to it (or inside of it), so particles overlap its geometry. The result is that attachment and collisions cause a force feedback loop, since neither can be solved. This situation, along with its solution, is described in the manual. See: http://obi.virtualmethodstudio.com/tutorials/pinconstraints.html The grab script is designed with kinematic rigidbodies or simple colliders in mind. In this case, simply attaching the rope slightly offsetted from the collider surface would suffice. |