terminalCode Example

VerletRope — rope physics with attachment, slack, and stiffness

calendar_today May 5, 2026 schedule ~1 min read person patrickjr verified 50

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

PropertyDescription
SegmentCountNumber of rope segments (more = smoother, costlier)
RadiusVisual thickness of the rope
SlackExtra length beyond straight-line distance
Stiffness0–1, how rigid the rope is
DampingFactor0–1, how quickly oscillation settles
AttachmentOptional 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?