Sandbox: Weld tool — FixedJoint constraint with EasyMode rotation
Sandbox Weld Tool — Constraint Creation with EasyMode Rotation
The Weld tool creates FixedJoint constraints between two GameObjects. It has an EasyMode that lets the player rotate the weld angle with the mouse before confirming.
Stages
The tool operates in 3 stages:
- Stage 0 — Select the first object (primary click)
- Stage 1 — Select the second object (primary click)
- Stage 2 (EasyMode only) — Rotate the weld angle with the mouse, confirm with primary click
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| EasyMode | bool | true | Enables the rotation stage before confirming |
| Rigid | bool | false | If true, AngularFrequency and LinearFrequency are set to 0 (perfectly rigid) |
Constraint structure
When a weld is created, two child GameObjects are spawned — one parented to each welded object:
point1.GameObject
└── "weld" (go1)
├── ConstraintCleanup (attachment = go2)
└── FixedJoint (body = go2, EnableCollision = true)
point2.GameObject
└── "weld" (go2)- ConstraintCleanup ensures the constraint is removed if either object is destroyed
- FixedJoint.EnableCollision = true — welded objects still collide with each other
- Soft welds: AngularFrequency = 10, LinearFrequency = 10
- Rigid welds: both frequencies = 0
EasyMode rotation
When EasyMode is on and both points are selected, AbsorbMouseInput returns true — the camera stops moving and Input.AnalogLook is used to rotate the weld angle. The moving object's WorldTransform is updated live as the player rotates.
Removing welds
Reload (R) removes all welds between the aimed object and any connected object. The tool finds welds via FixedJoint components in children with a matching ConstraintCleanup.Attachment.
Undo
Both go1 and go2 are added to the undo entry — undoing destroys both constraint GameObjects, which also removes the joint.
Snap grid integration
When a snap grid is active, SelectionPoint local positions are snapped to the nearest grid corner before the constraint is created.