terminalCode Example
VerletRope — rope physics with attachment, slack, and stiffness
VerletRope
VerletRope simulates rope physics using Verlet integration. The rope hangs from the GameObject's position and optionally attaches its end to another GameObject.Component Properties
| Property | Description |
|---|---|
| SegmentCount | Number of rope segments (more = smoother, costlier) |
| Radius | Visual thickness of the rope |
| Slack | Extra length beyond straight-line distance |
| Stiffness | 0–1, how rigid the rope is |
| DampingFactor | 0–1, how quickly oscillation settles |
| Attachment | Optional end-point GameObject |
Basic Rope Between Two Points
CSHARP
public sealed class RopeConnector : Component
{
[Property] public GameObject EndPoint { get; set; }
protected override void OnStart()
{
var rope = Components.Create<VerletRope>();
rope.Attachment = EndPoint;
rope.SegmentCount = 12;
rope.Radius = 1.5f;
rope.Slack = 20f;
rope.Stiffness = 0.8f;
rope.DampingFactor = 0.1f;
}
}Hanging Rope (No Attachment)
Without an attachment the rope hangs freely from the GO's position:
CSHARP
var rope = gameObject.Components.Create<VerletRope>();
rope.SegmentCount = 8;
rope.Radius = 2f;
rope.Slack = 50f; // how much it droops
rope.Stiffness = 0.5f;Taut vs Loose
CSHARP
// Taut cable
rope.Slack = 0f;
rope.Stiffness = 1f;
// Loose chain
rope.Slack = 80f;
rope.Stiffness = 0.3f;
rope.DampingFactor = 0.05f;Tips
- Keep SegmentCount under 20 for performance — most ropes look fine at 8–12.
- Slack is in world units added on top of the straight-line distance.
- Pair with a ModelRenderer or the rope renders as a line by default.
Was this helpful?