Skip to content

Rope Controller

The RopeController is the core architectural component in Tensio. It bridges the Unity scene hierarchy and GameObject transforms with the underlying multi-threaded XPBD physics solver. Every simulated rope requires exactly one RopeController.


Component Architecture

When attached to a GameObject, RopeController orchestrates:

  • Physics Simulation Loop: Scheduling and dispatching Burst-compiled distance, bending, and collision jobs.
  • Pinning Constraints: Enforcing spatial anchor attachments against static positions or dynamic Rigidbody instances.
  • Collision Detection: Raycasting/SphereCasting against layer masks or registering with analytical proxy colliders.
  • Curve Generation: Managing control points and tangents for spline interpolation.

Inspector Parameter Reference

1. Init Settings

These parameters define the base topological and geometric structure of the rope. Modifying these properties requires calling InitializeRope() or restarting Play Mode:

ParameterTypeDefaultDescription
TypeRopeTypeElasticChooses simulation and rendering archetype: Elastic (continuous tube) or Chain (instanced links).
Particle Countint20Resolution of the simulation (2 to 200). Higher counts produce smoother curves with slightly higher CPU cost.
Lengthfloat10.0Total resting length of the rope in meters.
LoopboolfalseWhen enabled, connects the final particle back to the first, creating a closed loop (rubber band / ring).

2. Physics Settings

Runtime parameters that govern physical behavior. These can be adjusted live in the Inspector or modified dynamically via C# scripts during gameplay:

ParameterTypeDefaultDescription
GravityVector3(0, -9.81, 0)Directional gravitational acceleration vector applied to all particles.
Sub Stepsint8Solver iterations per fixed physics frame (1 to 30). Higher values yield stiffer, ultra-stable constraints.
Compliancefloat0.0Inverse physical stiffness. 0.0 simulates inextensible steel cable; higher values create stretchy bungee cords.
Frictionfloat0.3Surface friction coefficient from 0.0 (frictionless ice) to 1.0 (high drag).
Particle Radiusfloat0.1Collision thickness radius around each simulated particle point.
Particle Massfloat1.0Individual particle mass in kilograms.
Break On StretchboolfalseEnables realistic tensile snapping when elongated past the safety threshold.
Max Stretch Ratiofloat1.3Stretch multiplier at which snapping triggers (e.g. 1.3 represents 30% elongation).
Collision MaskLayerMaskDefaultStandard Unity LayerMask defining objects the rope collides with via World SphereCast.
Support Inter-RopeboolfalseEnables mutual collisions with other ropes via RopeInteractionManager.
Visualize StretchbooltrueDynamically modulates renderer thickness or color under tension.

3. Aerodynamics Settings

Simulates environmental wind forces, air turbulence, and atmospheric drag:

ParameterTypeDefaultDescription
Wind DirectionVector3(1, 0, 0)Vector direction of atmospheric wind flow.
Wind Speedfloat0.0Base velocity force applied along the wind vector.
Turbulence Strengthfloat0.5Amplitude of procedural Perlin noise injected into the wind stream.
Air Dragfloat0.05Atmospheric movement resistance. Higher values simulate underwater drag or viscous fluids.

4. Pin Constraints

Anchors specific points of the rope to coordinates or GameObjects:

  • Particle Index: Which simulation particle is locked (0 = start of rope, Count - 1 = end of rope).
  • Target: Target Transform to track. If assigned to an object with a Rigidbody, forces are transferred bi-directionally.
  • Offset: Local position offset from the target transform’s pivot.