27-10-2017, 06:04 PM
(This post was last modified: 27-10-2017, 06:07 PM by josemendez.)
(27-10-2017, 12:40 PM)elfinik Wrote: 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);
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;
ObiPinConstraintBatch batch = (ObiPinConstraintBatch)constraints.GetBatches()[0];
// remove the constraints from the solver, because we cannot modify the constraints list while the solver is using it.
constraints.RemoveFromSolver(null);
// your code to add new constraints to the batch
// add all constraints back:
constraints.AddToSolver(null);