Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
End of the rope! Match position
#2
(07-08-2023, 03:12 PM)Renman3000 Wrote: Hi there, 
I have a rope. 

Is there a way to child a transform, renderer to the rope and specifuiclally a particle attachment so that this transform rednerer is always, whereever the selected particle attachment is, relative to its rope?

Basically, I would like a spehre to always be at the end of the rope.


Thanks

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,
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 josemendez - 09-08-2023, 07:11 AM