14-06-2021, 08:11 AM
(This post was last modified: 14-06-2021, 08:15 AM by josemendez.)
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:
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
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