Skip to content

HingeConstraint

Lets one part turn around an axis through a pivot point: doors, wheels, fans and trapdoors.

  • Inherits: Constraint → Instance
  • Creatable: Yes: new HingeConstraint(), or Instance.new('HingeConstraint', parent).
  • Replication: Replicated: clients get a copy, and changes the server makes reach them.

pivot0 and pivot1 are the same point seen from each part: where the joint attaches, relative to each part’s center, in the part’s own (rotated) axes. For a door hinged on its left edge to a post, pivot1 is the door’s left edge and pivot0 the matching point on the post. part1 turns around axis (in part0’s axes) through that point.

Angles are measured from the pose the parts are in when the hinge is created. Hinged parts don’t collide with each other, so a door can overlap its frame.

Type: Vector3 · Default: new Vector3(0, 0, 0) · Access: read/write · Replicates: yes

Where the joint attaches to part0, relative to its center (in the part’s own axes).

Type: Vector3 · Default: new Vector3(0, 0, 0) · Access: read/write · Replicates: yes

Where the joint attaches to part1, relative to its center (in the part’s own axes).

Type: Vector3 · Default: new Vector3(0, 1, 0) · Access: read/write · Replicates: yes

Turning axis in part0’s own axes ((0, 1, 0) is a door; 2D games always use Z).

Type: boolean · Default: false · Access: read/write · Replicates: yes

Drive the hinge at angularVelocity.

Type: number · Default: 0 · Range: -1,000 to 1,000 (clamped) · Access: read/write · Replicates: yes

Motor speed in radians per second (positive turns counter-clockwise around axis).

Type: number · Default: 100000 · Range: 0 to 1,000,000,000 (clamped) · Access: read/write · Replicates: yes

Strongest twist the motor applies.

Type: boolean · Default: false · Access: read/write · Replicates: yes

Keep the angle between lowerAngle and upperAngle.

Type: number · Default: -90 · Range: -180 to 180 (clamped) · Access: read/write · Replicates: yes

Degrees, from the pose when the hinge was created.

Type: number · Default: 90 · Range: -180 to 180 (clamped) · Access: read/write · Replicates: yes

Degrees, from the pose when the hinge was created.

Inherited from Constraint: part0, part1, enabled

Inherited from Instance: name, archivable, id, className, parent, destroyed

Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString

Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged

import { HingeConstraint, Part, Vector3, getChild, workspace } from '@rally/sdk';
const post = getChild(workspace, 'Post', Part); // anchored
const door = getChild(workspace, 'Door', Part); // 4 wide, anchored = false
const hinge = new HingeConstraint();
hinge.part0 = post;
hinge.part1 = door;
hinge.pivot0 = new Vector3(0.5, 0, 0); // the post's right face
hinge.pivot1 = new Vector3(-2, 0, 0); // the door's left edge
hinge.axis = new Vector3(0, 1, 0); // turn around Y
hinge.limitsEnabled = true; // swing between -90 and 90 degrees
hinge.parent = door;
// A motorized fan: spins at 6 radians per second.
const fan = new HingeConstraint();
fan.part0 = getChild(workspace, 'FanBase', Part);
fan.part1 = getChild(workspace, 'FanBlades', Part); // anchored = false
fan.axis = new Vector3(0, 0, 1);
fan.motorEnabled = true;
fan.angularVelocity = 6;
fan.motorMaxTorque = 1e6; // how hard it may push to keep that speed
fan.parent = workspace;