SixDofJoint
This component creates a six-degrees-of-freedom joint. It is the most configurable joint.
It can simulate any other joint, and more.
Two objects, node0 and node1, can be constrained along any translation or rotation axis.
For example, this joint can be used to make ragdolls.
The joint can be added as a component to either one of the two bodies, or to a new entity with a single joint component—the behavior of the joint will be the same.
Only one joint can be added to a single node.
This component is provided by the engine.physics_core module, which is included in the engine.core module.
Example:
require engine.core
// Create first body
let nodeA = create_node(NodeData(position = float3(0, 10, 10), scale = float3(1, 1, 10)))
add_component(nodeA, new RigidBody())
add_component(nodeA, new BoxCollider())
// Create second body
let nodeB = create_node(NodeData(position = float3(0, 10, -10), scale = float3(1, 1, 10)))
add_component(nodeB, new RigidBody())
add_component(nodeB, new BoxCollider())
// Create a joint that keeps two bodies at the distance they were created at — 20
add_component(create_node(NodeData(position = float3(0, 10, 0))), new SixDofJoint(
node0 = nodeA,
node1 = nodeB,
// allow some movement along the X and Z axes, but not along the Y axis
limitTranslation = float3(2, 0, 2),
// allow some rotation around the Y and Z axes, but not around the X axis
limitRotation = float3(0.0, PI / 4., PI / 4.)
))
Classes
- SixDofJoint : NativeComponent
The most configurable physics joint. It can also be used to simulate other joints.
- Properties:
- SixDofJoint.node0: NodeId
- SixDofJoint.node0 =(value: NodeId)
A first body of the joint. It should have an active RigidBody component.
- Arguments:
value : NodeId
- SixDofJoint.node1: NodeId
- SixDofJoint.node1 =(value: NodeId)
A second body of the joint. It should have an active RigidBody component.
- Arguments:
value : NodeId
- SixDofJoint.allowCollision: bool
- SixDofJoint.allowCollision =(value: bool)
Used for disabling collision between the joined bodies. Default is false, disables collision.
- Arguments:
value : bool
- SixDofJoint.limitTranslation: float3
- SixDofJoint.limitTranslation =(value: float3)
Allowed offset from the starting position by every axis. Set an axis to zero to prevent translation by this axis. Set it to FLT_MAX or any negative value to disable any constraints for this axis.
- Arguments:
value : float3
- SixDofJoint.limitRotation: float3
- SixDofJoint.limitRotation =(value: float3)
Allowed rotation around axes. Set an axis to zero to prevent rotation around this axis. Set it to PI * 2 or any negative value to disable any constraints for this axis.
- Arguments:
value : float3
- SixDofJoint.friction: float
- SixDofJoint.friction =(value: float)
Maximum friction force
- Arguments:
value : float
- SixDofJoint.frictionTorque: float
- SixDofJoint.frictionTorque =(value: float)
Maximum amount of torque to apply as friction
- Arguments:
value : float
- SixDofJoint.softTranslationLimit: float2
- SixDofJoint.softTranslationLimit =(value: float2)
Soft limit for translation. When one of the bodies tries to move out of allowed offsets, the soft limits can pull it with a spring force.
The spring settings are packed to float2 where x is a spring frequency in Hz, and y is a spring damping (0 = no damping, 1 = critical damping, >1 = overdamp).
If frequency = 0, the soft limit is disabled and the constraint will have hard limits.
- Arguments:
value : float2