Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Attaching non-Rigidbody object to rope
#1
Hi,

I'd like to attach an object to a specific particle group in the rope (I don't want to attach the rope to the object, I want to attach the object to the rope so that the object moves and rotates with the specified particle group of the rope). In other words, if the target particle group of the rope was a GameObject, I'd achieve my goal by making my object a child of the particle group.

My object doesn't have a Collider or Rigidbody. I don't want my object to collide with the rope or affect the rope's physics in any way.

I've attached an illustration to clarify things.

Thank you!

   
Reply
#2
(24-06-2020, 04:53 PM)flamingogs Wrote: Hi,

I'd like to attach an object to a specific particle group in the rope (I don't want to attach the rope to the object, I want to attach the object to the rope so that the object moves and rotates with the specified particle group of the rope). In other words, if the target particle group of the rope was a GameObject, I'd achieve my goal by making my object a child of the particle group.

My object doesn't have a Collider or Rigidbody. I don't want my object to collide with the rope or affect the rope's physics in any way.

I've attached an illustration to clarify things.

Thank you!

Hi,

You could just copy a particle's position/orientation over to your object's transform. There's only one issue: unlike rods, ropes do not define a full frame w/orientation. Rope particles only have a position.

You can somewhat work around this by asking the path smoother for the curve frame at a given point. This defines a frame orientation, but still, torsion  (rotation along the main rope axis) is not controllable. See the following thread:
http://obi.virtualmethodstudio.com/forum...-2204.html

Let me know if you need further help Sonrisa
Reply
#3
Thank you for the help. After looking at the topic you've mentioned, I've created the following script to accomplish my goal:

Code:
using Obi;
using UnityEngine;

public class MoveWithRope : MonoBehaviour
{
    public float normalizedCoord;
    public ObiPathSmoother path;

    private void LateUpdate()
    {
        ObiPathFrame section = path.GetSectionAt( normalizedCoord );
        transform.localPosition = section.position;
        transform.localRotation = Quaternion.LookRotation( section.tangent, section.normal );
    }

#if UNITY_EDITOR
    [ContextMenu( "Move to Coordinates" )]
    private void MoveToCoordinates()
    {
        UnityEditor.Undo.RecordObject( transform, "Move Object" );

        ObiPathFrame section = path.GetSectionAt( normalizedCoord );
        transform.localPosition = section.position;
        transform.localRotation = Quaternion.LookRotation( section.tangent, section.normal );
    }
#endif
}

Here's the simple workflow in case anyone else stumbles upon this topic:

1. Create an empty GameObject, attach this script to it and fill the variables via Inspector
2. Make the GameObject a child object of the rope
3. Right click the Move With Rope component and hit "Move to Coordinates". This will position the empty GameObject at the desired coordinates
4. At runtime, this empty GameObject will follow the desired coordinates. So you can put any attachment objects underneath it (make them its child objects)
Reply