Box2D. Box2dWheelJoint

Box2D Wheel Joint

  • Provides two degrees of freedom: translation along an axis fixed in objectA and rotation
  • You can use a joint motor to drive the motion or to model joint friction
  • This joint is designed for vehicle suspensions

Constructor

new Box2dWheelJoint(objectA, objectB, anchoropt, worldAxisopt, collideopt)

Create a wheel joint

Parameters:
NameTypeAttributesDefaultDescription
objectABox2dObject
objectBBox2dObject
anchorVector2<optional>

World position, objectB's position if not given

worldAxisVector2<optional>
collideboolean<optional>
false

Extends

  • Box2dJoint

Methods

enableMotor(enableopt)

Enable/disable the joint motor

Parameters:
NameTypeAttributesDefaultDescription
enableboolean<optional>
true

getJointSpeed() → {number}

Get the current joint rotation speed in radians per second, clockwise like angle, which is what this version of Box2D measures for a wheel joint

Returns:
Type: 
number

getJointTranslation() → {number}

Get the current joint translation

Returns:
Type: 
number

getLocalAnchorA() → {Vector2}

Get the local anchor point relative to objectA's origin

Returns:
Type: 
Vector2

getLocalAnchorB() → {Vector2}

Get the local anchor point relative to objectB's origin

Returns:
Type: 
Vector2

getLocalAxisA() → {Vector2}

Get the local joint axis relative to bodyA

Returns:
Type: 
Vector2

getMaxMotorTorque() → {number}

Get the max motor torque

Returns:
Type: 
number

getMotorSpeed() → {number}

Get the motor speed, clockwise like angle

Returns:
Type: 
number

getMotorTorque(timeopt) → {number}

Get the motor torque over the last step, clockwise like angle

Parameters:
NameTypeAttributesDescription
timenumber<optional>

The step length in seconds, the world steps by timeDelta

Returns:
Type: 
number

getSpringDampingRatio() → {number}

Get the spring damping ratio

Returns:
Type: 
number

getSpringFrequencyHz() → {number}

Get the spring frequency in Hertz

Returns:
Type: 
number

isMotorEnabled() → {boolean}

Is the joint motor enabled?

Returns:
Type: 
boolean

setMaxMotorTorque(torque)

Set the maximum motor torque, a magnitude

Parameters:
NameTypeDescription
torquenumber

setMotorSpeed(speed)

Set the motor speed, the wheel's turn in radians per second, clockwise like angle

Parameters:
NameTypeDescription
speednumber

setSpringDampingRatio(ratio)

Set the spring damping ratio

Parameters:
NameTypeDescription
rationumber

setSpringFrequencyHz(hz)

Set the spring frequency in Hertz

Parameters:
NameTypeDescription
hznumber