Revolute Joint 2D
Pins this body to the Target body at Anchor, with an optional limit and motor.
component physics.RevoluteJoint2D
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.
Scene3 nodes
Fields
| Name | Type | Default | Description |
|---|---|---|---|
| Target | NodeRef | none | The body this one turns around; both nodes need a Rigid Body 2D. |
| Anchor | Vec2 | (0, 0) | Pivot point in this node's space; both bodies turn around it. |
| Enable Limit | bool | false | Keeps the angle between Lower and Upper. |
| Lower | float | 0 | Smallest angle in radians, relative to the angle at start. |
| Upper | float | 0 | Largest angle in radians, relative to the angle at start. |
| Enable Motor | bool | false | Drives the joint at Speed, up to Max Torque. |
| Speed | float | 0 | Motor speed in radians per second; negative turns the other way. |
| Max Torque | float | 0 | Strongest torque the motor may apply; with 0 the motor does nothing. ≥ 0 |
| Collide Connected | bool | false | 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.
OnCollisionEnter— Runs after the physics step in which this body started touching other.OnCollisionExit— Runs when the bodies stop touching, including when one of them is destroyed or disabled. Contact.Point is the last known point.OnCollisionStay— Runs after every later physics step while the bodies keep touching. It costs nothing when no script declares it.OnTriggerEnter— Runs when other's collider entered a trigger of this body, or this body entered other's trigger.OnTriggerExit— Runs when the overlap with a trigger ends.
Related guides
- Components These components make a node part of the simulation.
- Physics 2D Aego simulates 2D rigid bodies with its own solver.