Connect two objects - 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: Connect two objects (/thread-215.html) |
Connect two objects - elfinik - 27-10-2017 Hello. I'm doing the game using obi physics, but after studying the documentation, I could not connect the two objects with a rope with the result I needed. I need to connect two points so that when the platform bends turned, the cube falls forward. I tried to adjust the distance, mass and stuff, but nothing happened. Points are selected through the script Code: localOPB.AddConstraint(0, firstTarget.GetComponent<ObiCollider>(), firstTarget.InverseTransformPoint(firstPoint), 0); Code: localOPB.AddConstraint(105, secondTarget.GetComponent<ObiCollider>(), secondTarget.InverseTransformPoint(secondPoint), 0); RE: Connect two objects - josemendez - 27-10-2017 (27-10-2017, 12:40 PM)elfinik Wrote: Hello. Hi! How are you updating the constraints? Are you adding them back to the solver after adding new constraints to the pin constraints batch? You must follow this pattern: Code: ObiPinConstraints constraints = rope.PinConstraints; RE: Connect two objects - elfinik - 30-10-2017 My problem is that I can not achieve the desired result. If the cube's mass is too small, the cube falls at the moment of connection. If the mass of the cube is larger, then it does not budge, even if the platform falls down and swings like a pendulum. The rope is disabled and turned on after adding new points. My code: Code: ObiPinConstraintBatch localOPB = new ObiPinConstraintBatch(false, false); RE: Connect two objects - josemendez - 31-10-2017 Hi, You don't need to create a new batch to put constraints in. By default, an empty pin constraints batch already exists. Also, these lines do nothing: rope.DistanceConstraints.RemoveFromSolver(null); rope.BendingConstraints.RemoveFromSolver(null); rope.BendingConstraints.AddToSolver(rope); rope.DistanceConstraints.AddToSolver(rope); You're removing the constraints, then adding back the exact same set of constraints, which does nothing. I don't think I quite understand the scene setup you're aiming for. The top-left cube is supposed to be attached to the rope, but when is it supposed to fall? |