menu_bookDocumentation
Sandbox: Hydraulic tool — motorized SliderJoint with LineRenderer shaft
Sandbox Hydraulic Tool — Motorized SliderJoint Constraints
The Hydraulic tool creates a SliderJoint between two objects with a HydraulicEntity component that can extend and retract the joint at runtime.
Two modes
Standard hydraulic (default): Creates two child GameObjects aligned along the axis between the two selection points, connected by a SliderJoint. A LineRenderer renders the shaft as a cylinder. Ball joint hydraulic (BallJoints = true): Uses BallSocketJoint at both ends with a SliderJoint in the middle, allowing the hydraulic to pivot freely at both attachment points.GameObject hierarchy (standard)
CODE
point1.GameObject
└── "hydraulic_a" (go1) — WorldRotation = LookAt(-line), tag: "constraint"
├── ConstraintCleanup (attachment = go2)
├── "hydraulic_cap_a" — ModelRenderer (tool_hydraulic.vmdl)
├── LineRenderer (points: [go1, go2], FaceMode.Cylinder)
└── "hydraulic" (jointGo)
├── SliderJoint (body = go2, MinLength = MaxLength = distance)
├── HydraulicEntity (Length=0.5, MinLength=5, MaxLength=dist*2)
└── CapsuleCollider
point2.GameObject
└── "hydraulic_b" (go2) — WorldRotation = LookAt(-line), tag: "constraint"
└── "hydraulic_cap_b" — ModelRenderer (tool_hydraulic.vmdl)HydraulicEntity
HydraulicEntity holds a reference to the SliderJoint and exposes Length, MinLength, MaxLength. At runtime, players can extend/retract the hydraulic by changing Length, which updates Joint.MinLength and Joint.MaxLength.Key properties
| Property | Default | Description |
|---|---|---|
| BallJoints | false | Use ball socket joints at both ends |
| Initial MinLength / MaxLength | distance between points | Locked at creation distance |
| HydraulicEntity.MinLength | 5.0 | Minimum extension |
| HydraulicEntity.MaxLength | dist * 2 | Maximum extension |
Removal
Reload (R) removes all hydraulics between the aimed object and any connected object, found via HydraulicEntity components in ConstraintCleanup children.
Visual
The shaft uses a LineRenderer with FaceMode.Cylinder, the metaltileline.vmat material, WorldSpace = true, and UnitsPerTexture = 32 for a tiling metal texture that scales with length.
Was this helpful?