Box2D 3.2.0
A 2D physics engine for games
Loading...
Searching...
No Matches

Functions for the motor joint. More...

Data Structures

struct  b2MotorJointDef
 A motor joint is used to control the relative velocity and/or transform between two bodies. More...

Functions

b2JointId b2CreateMotorJoint (b2WorldId worldId, const b2MotorJointDef *def)
 Create a motor joint.
void b2MotorJoint_SetLinearVelocity (b2JointId jointId, b2Vec2 velocity)
 Set the desired relative linear velocity in meters per second.
b2Vec2 b2MotorJoint_GetLinearVelocity (b2JointId jointId)
 Get the desired relative linear velocity in meters per second.
void b2MotorJoint_SetAngularVelocity (b2JointId jointId, float velocity)
 Set the desired relative angular velocity in radians per second.
float b2MotorJoint_GetAngularVelocity (b2JointId jointId)
 Get the desired relative angular velocity in radians per second.
void b2MotorJoint_SetMaxVelocityForce (b2JointId jointId, float maxForce)
 Set the motor joint maximum force, usually in newtons.
float b2MotorJoint_GetMaxVelocityForce (b2JointId jointId)
 Get the motor joint maximum force, usually in newtons.
void b2MotorJoint_SetMaxVelocityTorque (b2JointId jointId, float maxTorque)
 Set the motor joint maximum torque, usually in newton-meters.
float b2MotorJoint_GetMaxVelocityTorque (b2JointId jointId)
 Get the motor joint maximum torque, usually in newton-meters.
void b2MotorJoint_SetLinearHertz (b2JointId jointId, float hertz)
 Set the spring linear hertz stiffness.
float b2MotorJoint_GetLinearHertz (b2JointId jointId)
 Get the spring linear hertz stiffness.
void b2MotorJoint_SetLinearDampingRatio (b2JointId jointId, float damping)
 Set the spring linear damping ratio. Use 1.0 for critical damping.
float b2MotorJoint_GetLinearDampingRatio (b2JointId jointId)
 Get the spring linear damping ratio.
void b2MotorJoint_SetAngularHertz (b2JointId jointId, float hertz)
 Set the spring angular hertz stiffness.
float b2MotorJoint_GetAngularHertz (b2JointId jointId)
 Get the spring angular hertz stiffness.
void b2MotorJoint_SetAngularDampingRatio (b2JointId jointId, float damping)
 Set the spring angular damping ratio. Use 1.0 for critical damping.
float b2MotorJoint_GetAngularDampingRatio (b2JointId jointId)
 Get the spring angular damping ratio.
void b2MotorJoint_SetMaxSpringForce (b2JointId jointId, float maxForce)
 Set the maximum spring force in newtons.
float b2MotorJoint_GetMaxSpringForce (b2JointId jointId)
 Get the maximum spring force in newtons.
void b2MotorJoint_SetMaxSpringTorque (b2JointId jointId, float maxTorque)
 Set the maximum spring torque in newtons * meters.
float b2MotorJoint_GetMaxSpringTorque (b2JointId jointId)
 Get the maximum spring torque in newtons * meters.
b2MotorJointDef b2DefaultMotorJointDef (void)
 Use this to initialize your joint definition.

Detailed Description

Functions for the motor joint.

The motor joint is designed to control the movement of a body while still being responsive to collisions. A spring controls the position and rotation. A velocity motor can be used to control velocity and allows for friction in top-down games. Both types of control can be combined. For example, you can have a spring with friction. Position and velocity control have force and torque limits.


Data Structure Documentation

◆ b2MotorJointDef

struct b2MotorJointDef

A motor joint is used to control the relative velocity and/or transform between two bodies.

With a velocity of zero this acts like top-down friction.

Data Fields
float angularDampingRatio Angular spring damping ratio.
float angularHertz Angular spring hertz for position control.
float angularVelocity The desired angular velocity.
b2JointDef base Base joint definition.
int internalValue Used internally to detect a valid definition. DO NOT SET.
float linearDampingRatio Linear spring damping ratio.
float linearHertz Linear spring hertz for position control.
b2Vec2 linearVelocity The desired linear velocity.
float maxSpringForce Maximum spring force in newtons.
float maxSpringTorque Maximum spring torque in newton-meters.
float maxVelocityForce The maximum motor force in newtons.
float maxVelocityTorque The maximum motor torque in newton-meters.

Function Documentation

◆ b2CreateMotorJoint()

b2JointId b2CreateMotorJoint ( b2WorldId worldId,
const b2MotorJointDef * def )

Create a motor joint.

See also
b2MotorJointDef for details