Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
End of the rope! Match position
#5
(09-08-2023, 07:11 AM)josemendez Wrote: Hi,

There's many ways to do this, depending on what you want exactly.

If you want to make sure a transform is always at the position of the last particle in the rope, you can just set the position of the transform to the position of the last particle:

Code:
int lastParticle = rope.elements[rope.elements.Count-1].particle2;
transform.position = rope.solver.TransformPoint(rope.solver.positions[lastParticle]);

Another option is to retrieve the position of the last frame in the rope, which will provide you with orientation information as well. You do this by using
Code:
var frame = rope.GetComponent<ObiPathSmoother>().GetSectionAt(1); // normalized coord from 0/start to 1/end
transform.position = frame.position;
transform.rotation = Quaternion.LookRotation(frame.tangent, frame.binormal);

A third option is to use the utility ObiRopeAttach component, which implements the second option (GetSectionAt) so you don't have to write it yourself.


kind regards,
Thanks!
Reply


Messages In This Thread
End of the rope! Match position - by Renman3000 - 07-08-2023, 03:12 PM
RE: End of the rope! Match position - by Renman3000 - 09-08-2023, 07:11 PM