Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to attach a GameObject to a rope from script?
#6
You're passing Vector3.zero as the pin offset. This means the pinned particle will shift to the exact center of the rigidbody as soon as you activate the constraint.

Pass the current particle's position in local space instead, so that it doesn't move. Something like this:
Code:
var localPos = body.transform.InverseTransformPoint(solver.transform.TransformPoint(solver.positions[index]));

Remember that Unity's TransformPoint/Vector/Direction and InverseTransformPoint/Vector/Direction let you convert data from local to world space and vice-versa. You should get very comfortable with these:
https://docs.unity3d.com/ScriptReference...Point.html
https://docs.unity3d.com/ScriptReference...Point.html
Reply


Messages In This Thread
RE: How to attach a GameObject to a rope from script? - by josemendez - 14-06-2021, 08:11 AM