Aego Русский

Revolute Joint 2D

Pins this body to the Target body at Anchor, with an optional limit and motor.

component physics.RevoluteJoint2D
On this page

Try it

Drive a revolute joint

The cyan arm is a dynamic body pinned to the gray static pivot. Its enabled motor initially targets zero speed.

Set Speed to 6 radians per second. The real joint motor rotates the body around the pivot. Reset returns it to rest.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene3 nodes
Pivot
Transform
position[-2, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#d1d5dbffsizeVec2[0.4, 0.4]orderint1
Arm
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#38bdf8ffsizeVec2[4, 0.8]
Rigid Body 2D
typeenumdynamicgravityScalefloat0allowSleepboolfalseinterpolateboolfalse
Revolute Joint 2D
targetNodeRefnode("d3500000000000000000000000000001")anchorVec2[-2, 0]enableMotorbooltruespeedfloat0maxTorquefloat200
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue

Fields

NameTypeDefaultDescription
TargetNodeRefnone

The body this one turns around; both nodes need a Rigid Body 2D.

AnchorVec2(0, 0)

Pivot point in this node's space; both bodies turn around it.

Enable Limitboolfalse

Keeps the angle between Lower and Upper.

Lowerfloat0

Smallest angle in radians, relative to the angle at start.

Upperfloat0

Largest angle in radians, relative to the angle at start.

Enable Motorboolfalse

Drives the joint at Speed, up to Max Torque.

Speedfloat0

Motor speed in radians per second; negative turns the other way.

Max Torquefloat0

Strongest torque the motor may apply; with 0 the motor does nothing.

≥ 0
Collide Connectedboolfalse

Lets the two connected bodies collide with each other.

From a script

Open a door with the joint motor and let it swing freely when the motor is off.

package level

script Door {
    var Open bool

    func Toggle() {
        Open = !Open
        hinge := node.Get<RevoluteJoint2D>()
        hinge.EnableMotor = Open
        hinge.Speed = 1.5
        hinge.MaxTorque = 200
    }
}

Script events

Scripts on a node with this component receive these events from the Physics 2D module.