codeAPI Reference
s&box BallSocketPair: Hydraulic ball socket visual
BallSocketPair Component API Reference
BallSocketPair is a Component that aligns two ball socket models towards each other and updates a line renderer between them. Used for visual representation of hydraulic ball socket joints.
Type Signature
CSHARP
public class BallSocketPair : Component
{
[Property] public SkinnedModelRenderer BallModelA { get; set; }
[Property] public SkinnedModelRenderer BallModelB { get; set; }
[Property] public LineRenderer ShaftRenderer { get; set; }
}Properties
- SkinnedModelRenderer BallModelA { get; set; } - First ball socket model
- SkinnedModelRenderer BallModelB { get; set; } - Second ball socket model
- LineRenderer ShaftRenderer { get; set; } - Line renderer for the shaft between balls
Behavior
In OnUpdate:
- Calculates direction vector between BallModelA and BallModelB
- Aligns both ball models to face each other (pitch -90 degrees)
- Handles vertical alignment (uses Forward instead of Up when nearly vertical)
- Updates LineRenderer points between bone "end" objects on both models
Usage
CSHARP
// Attach to a hydraulic GameObject with ball socket models
var ballPair = GameObject.Components.Create<BallSocketPair>();
ballPair.BallModelA = modelA;
ballPair.BallModelB = modelB;
ballPair.ShaftRenderer = shaftLine;Notes
- Models must have a bone named "end" for line renderer attachment
- Ball models are rotated to face each other with -90 degree pitch
- Shaft renderer connects the "end" bones of both models
- Used by Hydraulic tool for visual feedback
- Updates every frame in OnUpdate
Was this helpful?