Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connect two objects
#2
(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);


[Image: 737fa4f5889a5ab1c6d8ac41d1c43587.png]

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);
Reply


Messages In This Thread
Connect two objects - by elfinik - 27-10-2017, 12:40 PM
RE: Connect two objects - by josemendez - 27-10-2017, 06:04 PM
RE: Connect two objects - by elfinik - 30-10-2017, 09:29 PM
RE: Connect two objects - by josemendez - 31-10-2017, 02:37 PM