11-05-2023, 03:28 AM
(This post was last modified: 11-05-2023, 03:30 AM by Balin.
Edit Reason: Clarify particle attachments.
)
Hi there,
I'm trying to develop a simulation of a ship mooring line breaking and snapping back. So far I've been able to get the rope to tear at one end programmatically, and it looks pretty good, but there are a few problems I'd like to solve:
1. How does one increase the speed the rope flings back after being broken? I would assume it's tied to the tension, but I'm not 100% sure how to increase the tension without shrinking the rope (see below), which is what I saw suggested on another forum post here. Ideally I'd like a different way of doing this.
2. After breaking the rope, it seemingly gets a lot smaller than its original size. See the images attached. In the custom script I wrote, I use a Cursor to reduce the size of the rope at the start so that the tension is increased. However, after breaking, it seems to get much smaller than what I set it to. Ideally I would like the rope to maintain its original length after being broken, so it could fling back and potentially reach its full length in the opposite direction.
Here's my very simple code so far:
Just to note:
Hopefully you understand my issue and what I would like to achieve here.
Cheers,
Balin
I'm trying to develop a simulation of a ship mooring line breaking and snapping back. So far I've been able to get the rope to tear at one end programmatically, and it looks pretty good, but there are a few problems I'd like to solve:
1. How does one increase the speed the rope flings back after being broken? I would assume it's tied to the tension, but I'm not 100% sure how to increase the tension without shrinking the rope (see below), which is what I saw suggested on another forum post here. Ideally I'd like a different way of doing this.
2. After breaking the rope, it seemingly gets a lot smaller than its original size. See the images attached. In the custom script I wrote, I use a Cursor to reduce the size of the rope at the start so that the tension is increased. However, after breaking, it seems to get much smaller than what I set it to. Ideally I would like the rope to maintain its original length after being broken, so it could fling back and potentially reach its full length in the opposite direction.
Here's my very simple code so far:
Code:
public class TensionScript : MonoBehaviour
{
public Transform attachmentA;
public Transform attachmentB;
public float timeScale;
public bool reduceLength;
public float length;
ObiRope rope;
void Start()
{
Time.timeScale = timeScale;
rope = GetComponent<ObiRope>();
if(reduceLength) GetComponent<ObiRopeCursor>().ChangeLength(Vector3.Distance(attachmentA.position, attachmentB.position) * length);
}
[ContextMenu("Tear")]
void TearRope()
{
rope.Tear(rope.elements[rope.elements.Count - 1]);
rope.RebuildConstraintsFromElements();
}
}
Just to note:
- The rope only has two control points, one at each end.
- All the bend and distance constraint options are set to 0. I believe this makes the rope as rigid as I want it, but let me know if I should change anything here.
- Both ends have an ObiParticleAttachment on them.
- After breaking, the rope swings around the bollard seemingly indefinitely, even though I have a dampening value set on the solver. Not sure what causes this.
Hopefully you understand my issue and what I would like to achieve here.
Cheers,
Balin