24-06-2020, 08:17 PM
Thank you for the help. After looking at the topic you've mentioned, I've created the following script to accomplish my goal:
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)
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)