09-08-2023, 07:11 PM
(09-08-2023, 07:11 AM)josemendez Wrote: Hi,Thanks!
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,