Build a Physics Door with a Banter Hinge Joint
HingeJoint rotates around one axis and is the documented joint type for a door-like mechanism. A working two-body setup needs a frame rigidbody, a door rigidbody, colliders, and a hinge whose connectedBody is the frame rigidbody's ID.
Create the frame first, keep its rigidbody reference, then build the door and connect its hinge to the frame rigidbody ID.
- Create frame and door GameObjects with matching visual and collider dimensions.
- Add rigidbodies and keep the returned frame rigidbody reference.
- Add a HingeJoint to the door with anchor, axis, limits, and
connectedBody.
Create the Frame
const frame = new BS.GameObject({
name: "DoorFrame",
localPosition: new BS.Vector3(0, 1.25, 3)
});
frame.AddComponent(new BS.BanterBox({
width: 1.4,
height: 2.5,
depth: 0.2
}));
frame.AddComponent(new BS.BoxCollider({
size: new BS.Vector3(1.4, 2.5, 0.2)
}));
const frameBody = frame.AddComponent(
new BS.BanterRigidbody({
isKinematic: true,
useGravity: false
})
);
The frame's rigidbody supplies the ID used by the door hinge.
Create the Door
const door = new BS.GameObject({
name: "Door",
localPosition: new BS.Vector3(0, 1.25, 2.85)
});
door.AddComponent(new BS.BanterBox({
width: 1.2,
height: 2.3,
depth: 0.12
}));
door.AddComponent(new BS.BoxCollider({
size: new BS.Vector3(1.2, 2.3, 0.12)
}));
door.AddComponent(new BS.BanterRigidbody({
mass: 2,
useGravity: true,
isKinematic: false
}));
Keep the door collider close to the visible dimensions.
Add the Hinge
door.AddComponent(new BS.HingeJoint({
anchor: new BS.Vector3(-0.6, 0, 0),
axis: new BS.Vector3(0, 1, 0),
autoConfigureConnectedAnchor: true,
useLimits: true,
limits: new BS.JointLimits({
bounciness: 0,
bounceMinVelocity: 0,
contactDistance: 0,
min: 0,
max: 110
}),
useMotor: false,
useSpring: false,
enableCollision: false,
connectedBody: frameBody.id
}));
The hinge axis is vertical in this example. The anchor sits on the left edge of a door whose width is 1.2.
Why connectedBody Matters
The official Banter reference states that connectedBody must be the ID of the rigidbody on the other GameObject. Without it, the hinge connects to world space.
Add Grab Interaction
If the door should be directly grabbed, add the documented grab component:
door.AddComponent(new BS.BanterGrababble({
grabType: BS.BanterGrabType.Default,
grabRadius: 0.01
}));
Use the exact API spelling BanterGrababble.
Adjust the Door
If the door rotates incorrectly, inspect:
- the door and frame transforms
- hinge anchor
- hinge axis
- connected anchor
- minimum and maximum limits
- frame rigidbody ID
- collision between the connected objects
Change one value at a time and retest the resting and fully open positions.
Common Questions
Why is my Banter door hinged to world space?
Set connectedBody to the id of the frame's BanterRigidbody component.
Why does the Banter door rotate around its centre?
Move the hinge anchor to the door edge and confirm the axis points along the intended hinge line.
Official References
Related Navigation
- Banter Physics Joints
- Banter Physics and Grabbable Objects
- Banter Raycasts and Object Events
- Banter VR Documentation