Skip to main content

CrankControlledRope

A class in Root.Township, the global namespace.

Visual only: stretches a rope LineRenderer and moves its end point as a Crank turns. Sits on the crank prefab.

Constructors​

MemberWhat it is
CrankControlledRope()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private Crank crankThe Crank whose value drives the rope length.
private Vector3 directionLocal direction the rope extends in.
private Transform lineEndTransform at the rope's end, moved to the new length each update.
private AnimationCurve lineLengthCurve from crank value (0 to 1) to rope length; defaults to 0 to 0.3.
private LineRenderer ropeRendererThe LineRenderer that draws the rope.

Methods​

2 private and internal methods
MemberWhat it is
private void Awake()Subscribes UpdateLineRenderer to the crank's ValueChanged event.
private void UpdateLineRenderer(Crank crank, float crankValue)Moves lineEnd and the rope's first point along direction by lineLength evaluated at the crank value.