Obi Official Forum
Moving object along the rope - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Moving object along the rope (/thread-3243.html)



Moving object along the rope - sodach1 - 20-12-2021

Hi guys. Can anyone give me an advice on which features to use to attach an object to a rope and move it along, like along a dynamic spline?
    I wanted to use Particle Attachment and move the path point assigned in there, but as far as I understood, you can't move path points like this. So the thing is what should I do?


RE: Moving object along the rope - josemendez - 21-12-2021

(20-12-2021, 08:57 PM)sodach1 Wrote: Hi guys. Can anyone give me an advice on which features to use to attach an object to a rope and move it along, like along a dynamic spline?
    I wanted to use Particle Attachment and move the path point assigned in there, but as far as I understood, you can't move path points like this. So the thing is what should I do?

You can use:

Code:
var section = rope.GetComponent<ObiPathSmoother>().GetSectionAt(float mu);

GetSectionAt() takes a normalized coordinate as input (a float from 0 to 1, 0 being the start of the rope and 1 being the end) and returns a struct containing position, normal, tangent and bitangent (a full orthonormal frame) of the rope at that point.

Also see the utility script /Obi/Scripts/RopeAndRod/Utils/ObiRopeAttach.cs for an example of how to use it to place an object along the rope.


RE: Moving object along the rope - sodach1 - 21-12-2021

(21-12-2021, 08:11 AM)josemendez Wrote: You can use:

Code:
var section = rope.GetComponent<ObiPathSmoother>().GetSectionAt(float mu);

GetSectionAt() takes a normalized coordinate as input (a float from 0 to 1, 0 being the start of the rope and 1 being the end) and returns a struct containing position, normal, tangent and bitangent (a full orthonormal frame) of the rope at that point.

Also see the utility script /Obi/Scripts/RopeAndRod/Utils/ObiRopeAttach.cs for an example of how to use it to place an object along the rope.

Thanks for your answer!

The actual behaviour I want to achieve is firstly hook an object on the rope and then move it back and forth while it's on rope.
Now I am thinking about attachment process. If I use GetSectionAt, I will need to pass mu to get the position, but it could be attached somewhere in the middle of the rope, so how mu can be calculated, or maybe there's another way of doing this all?


RE: Moving object along the rope - josemendez - 21-12-2021

(21-12-2021, 02:15 PM)sodach1 Wrote: Thanks for your answer!

The actual behaviour I want to achieve is firstly hook an object on the rope and then move it back and forth while it's on rope.
Now I am thinking about attachment process. If I use GetSectionAt, I will need to pass mu to get the position, but it could be attached somewhere in the middle of the rope, so how mu can be calculated, or maybe there's another way of doing this all?

mu ranges from 0 (start of the rope) to 1 (end of the rope). So to attach it in the middle, use 0.5.

If you mean you want the object to "slide" over the rope while driven by physics (imagine a sphere with a hole trough it, and the rope passing trough this hole, like a necklace bead), that's considerably more complex to do. You'll need to write your own rigidbody physics joint to do that, which is outside of the scope of Obi.