Suspension

Package: Libraries.Game.Physics.Vehicles · Inherits from: Libraries.Language.Object

The Suspension class stores the setup and current state for one vehicle wheel. Create a Suspension for each wheel, set its connection point, direction, axle, rest length, and radius, and add it to a Vehicle with Add. You can then set that wheel's spring, damping, steering, engine, and brake values. The vehicle updates each wheel during every physics step and uses the wheel state to calculate forces between the chassis and the ground. The wheel's connection point, suspension direction, and axle are relative to the chassis. Give the wheel an Item3D so it has a visible model in the scene.

Actions

GetAxle()

Returns the wheel axle direction in chassis space. It describes the side-to-side axis the wheel spins around, relative to the chassis: +X is right, +Y is up, and +Z is forward. The vehicle rotates this direction with the chassis to find the axle in world space. It also uses the axle to calculate the tire's sideways friction force.

Returns

Libraries.Compute.Vector3

GetAxleWorldSpace()

Returns the wheel axle direction in world space. This is the chassis-space axle direction rotated to match the chassis's current orientation.

Returns

Libraries.Compute.Vector3

GetBrake()

Returns this wheel's braking force, in newtons. The brake is used when the wheel touches the ground and has no engine force. Zero means no braking.

Returns

number

GetConnectionPoint()

Returns the wheel's suspension connection point in chassis space. This is a position offset from the chassis rigid body's local origin, measured in the vehicle's distance units. The vehicle rotates and adds this offset to the chassis position to find where the suspension ray starts in world space.

Returns

Libraries.Compute.Vector3

GetContactNormalWorldSpace()

Returns the ground surface's contact normal in world space. The normal points out from the surface at the contact point; for flat ground, it usually points up, such as (0, 1, 0).

Returns

Libraries.Compute.Vector3

GetContactPointWorldSpace()

Returns the wheel's contact point in world space. This is the exact point where the suspension ray hits the ground, such as (2, 0, 5) when the wheel touches a flat ground surface at X=2 and Z=5.

Returns

Libraries.Compute.Vector3

GetDampingCompression()

Returns the damping used while the suspension compresses. Compression happens when a wheel moves up toward a chassis, such as when it rolls over a bump, making the suspension shorter. Damping resists this motion and reduces bounce. Use 0 or greater, although no upper limit is enforced. A common starting value might be around 0.83.

Returns

number

GetDampingRelaxation()

Returns the damping used while the suspension extends. Extension happens when the suspension gets longer, such as when the wheel moves down after passing over a bump. Damping resists this motion and reduces bouncing. Use 0 or greater with no enforced upper limit. A typical value might be around 0.88.

Returns

number

GetDeltaRotation()

Returns how far, in radians, the wheel spun during the latest vehicle update. While the wheel is off the ground, it keeps spinning by this amount and slows down a little each update.

Returns

number

GetDirection()

Returns the fixed suspension ray direction in chassis space. The direction is relative to the chassis axes, not the world axes. For example, (0, -1, 0) points down from the chassis. As the chassis moves or turns, the vehicle rotates this direction to find the ray's direction in world space.

Returns

Libraries.Compute.Vector3

GetDirectionWorldSpace()

Returns the suspension ray's direction in world space. This is the chassis- space suspension direction rotated to match the chassis's current orientation.

Returns

Libraries.Compute.Vector3

GetEngineForce()

Returns the engine force assigned to this wheel. When the wheel touches the ground, this force is applied along the tire's forward direction. Zero means no engine force. A negative value applies force in reverse.

Returns

number

GetFrictionSlip()

Returns this wheel's tire grip setting. It sets how much sideways and forward force the tire can transfer to the ground before it starts to slide. This is a simulation grip value, not a direct real-world friction coefficient. Use 0 or greater. No upper limit is enforced. A typical starting value might be around 10.5.

Returns

number

GetGroundBody()

Returns the object beneath this wheel when its suspension ray hits a surface. The vehicle uses this object to apply the wheel's forces to the ground. It is undefined for a physics step in which the suspension ray hits no ground object.

Returns

Libraries.Interface.Item3D

GetInContact()

Returns whether this wheel's suspension ray hit a collision object during the latest vehicle update. This means the ray found a surface, not that a solid wheel shape physically touched it.

Returns

boolean

GetMaxSuspensionForce()

Returns the maximum support force from this wheel's suspension. When the wheel is pressed against the ground, the spring and damper push the chassis away from the surface. This value caps that push at this wheel. Use 0 or greater. The setter does not enforce a range. A typical starting value might be around 6000.

Returns

number

GetMaxSuspensionTravel()

Returns how far, in meters, the suspension can move from its rest length. When the wheel touches the ground, its suspension length is kept between the rest length minus this value and the rest length plus this value. The default is 5 meters. The default is 5 meters.

Returns

number

GetRadius()

Returns the radius of the wheel used by the suspension ray and to find the wheel's position from the ground contact point.

Returns

number

GetRestLength()

Returns the suspension's starting length. This value stays the same while the vehicle moves.

Returns

number

GetRollInfluence()

Returns how much sideways tire force can roll the chassis. This setting scales the height of the force's application point. A value of 0 removes its roll leverage, while 1 uses the full height. Use 0 to 1 for normal behavior, though the setter does not enforce this range. A typical starting value might be around 0.1.

Returns

number

GetSteering()

Returns this wheel's steering angle in radians. Zero means straight ahead. Positive and negative values turn the wheel in opposite directions. This angle changes the wheel's direction only when steering is enabled.

Returns

number

GetSuspensionChassisPoint()

Returns the point on the chassis where this wheel's suspension impulse is applied, measured from the chassis's center of mass. The vehicle uses this offset to apply the impulse at the wheel's ground contact point, which can also affect how the chassis turns.

Returns

Libraries.Compute.Vector3

GetSuspensionForce()

Returns the suspension force calculated for this wheel during the latest vehicle update. When the wheel is in contact, this force pushes the chassis away from the surface. It ranges from 0 to maxSuspensionForce. With no contact, it is 0.

Returns

number

GetSuspensionGroundPoint()

Returns the ground contact point for this wheel's suspension, measured from the ground body's center of mass. The vehicle uses this offset to find the ground body's velocity at the contact point when calculating suspension motion.

Returns

Libraries.Compute.Vector3

GetSuspensionImpulse()

Returns the impulse produced by this wheel's suspension for the current physics step. It points along the ground contact's normal, and its size depends on the suspension force and the length of the physics step. The vehicle applies it to the chassis to push it away from the ground.

Returns

Libraries.Compute.Vector3

GetSuspensionLength()

Returns the suspension's current length. This value changes as the suspension compresses or extends.

Returns

number

GetSuspensionOriginWorldSpace()

Returns the world-space starting point of the suspension ray. It is calculated from the wheel's connection point on the chassis and moves with the chassis.

Returns

Libraries.Compute.Vector3

GetSuspensionStiffness()

Returns the suspension spring stiffness. Use 0 or greater. There is no upper limit. The default is 5.88, which is Bullet's default.

Returns

number

GetTireChassisPoint()

Returns the wheel's tire contact point relative to the chassis's center of mass. The vehicle uses this offset to apply tire impulses to the chassis at the contact point, which can also affect how the chassis turns.

Returns

Libraries.Compute.Vector3

GetTireForwardImpulse()

Returns this wheel's forward tire impulse for the current physics step. The vehicle calculates it from engine force or braking, then applies it to the chassis along the tire's forward direction to drive or slow the vehicle.

Returns

Libraries.Compute.Vector3

GetTireGroundPoint()

Returns the wheel's tire contact point relative to the ground body's center of mass. The vehicle uses this offset to apply the sideways tire impulse to a movable ground body at the contact point.

Returns

Libraries.Compute.Vector3

GetTireImpulse()

Returns the total tire impulse for this wheel during the current physics step. It combines the forward impulse that drives or brakes the vehicle with the sideways impulse that helps the tire grip the ground. The vehicle applies these impulses at the wheel's ground contact point.

Returns

Libraries.Compute.Vector3

GetTireSideImpulse()

Returns this wheel's sideways tire impulse for the current physics step. The vehicle calculates it from the tire's grip and sideways motion, then applies it at the contact point to resist sliding and help steer the chassis.

Returns

Libraries.Compute.Vector3

GetVisual()

Returns the Item3D used to show this wheel in the scene. For example, this may be a cylinder or model positioned at the wheel's current world-space location. It is undefined by default.

Returns

Libraries.Interface.Item3D

GetVisualPartRestPositions()

Returns each visual child's position relative to its parent at the time SetVisual was called.

Returns

Libraries.Containers.Array<Libraries.Compute.Vector3>

GetVisualPartRestRotations()

Returns each visual child's rotation at the time SetVisual was called.

Returns

Libraries.Containers.Array<Libraries.Compute.Matrix4>

GetVisualParts()

Returns the visual's children, in the same order as the rest rotations and positions recorded by SetVisual.

Returns

Libraries.Containers.Array<Libraries.Interface.Item3D>

GetVisualRestRotation()

Returns the visual's rotation at the time SetVisual was called.

Returns

Libraries.Compute.Matrix4

GetWheelRotation()

Returns this wheel's spin angle around its axle, in radians. Zero means no rotation. The vehicle updates this value from the wheel's rolling speed and uses it to rotate the wheel's visual item.

Returns

number

IsSteeringEnabled()

Returns whether steering input changes this wheel's direction.

Returns

boolean

SetAxle(Libraries.Compute.Vector3 axleRelativeToChassis)

Sets the wheel axle direction in chassis space. The direction is relative to the chassis, not the world: +X is right, +Y is up, and +Z is forward. The vehicle rotates it with the chassis when calculating the wheel direction and sideways tire friction.

Parameters

SetAxleWorldSpace(Libraries.Compute.Vector3 axleWorldSpace)

Sets the wheel axle direction in world space. The vehicle uses this direction to calculate tire forces at the ground contact point.

Parameters

SetBrake(number brake)

Sets this wheel's braking force, in newtons. The brake slows the chassis along the wheel's forward direction when the wheel touches the ground and has no engine force. Use 0 or greater. This setter stores the value as given, while Vehicle.SetBrake changes negative values to 0.

Parameters

  • brake number

SetConnectionPoint(Libraries.Compute.Vector3 connectionPointRelativeToChassis)

Sets the wheel's suspension connection point in chassis space. This is a position offset from the chassis rigid body's local origin, not a world position. The vehicle rotates and adds this offset to the chassis position to find where the suspension ray starts in world space.

Parameters

SetContactNormalWorldSpace(Libraries.Compute.Vector3 contactNormalWorldSpace)

Sets the ground surface's contact normal in world space. For example, use (0, 1, 0) for flat ground, or the upward-facing normal of a slope.

Parameters

SetContactPointWorldSpace(Libraries.Compute.Vector3 contactPointWorldSpace)

Sets the wheel's contact point in world space. For example, set this to (2, 0, 5) when the wheel touches a flat ground surface at X=2 and Z=5.

Parameters

SetDampingCompression(number dampingCompression)

Sets the damping used while the suspension compresses. Use 0 or greater, although no upper limit is enforced. This value controls how strongly the suspension resists shortening as the wheel moves up toward the chassis. A value of 0 means no compression damping.

Parameters

  • dampingCompression number

SetDampingRelaxation(number dampingRelaxation)

Sets the damping used while the suspension extends. Use 0 or greater with no enforced upper limit. This value controls how strongly the suspension resists getting longer as the wheel moves down. A typical value might be around 0.88.

Parameters

  • dampingRelaxation number

SetDeltaRotation(number deltaRotation)

Sets how far, in radians, the wheel spins each update while off the ground.

Parameters

  • deltaRotation number

SetDirection(Libraries.Compute.Vector3 directionRelativeToChassis)

Sets the fixed suspension ray direction in chassis space. The direction is relative to the chassis axes, not the world axes. For example, (0, -1, 0) points down from the chassis. The vehicle rotates this direction with the chassis to find the ray's direction in world space.

Parameters

SetDirectionWorldSpace(Libraries.Compute.Vector3 directionWorldSpace)

Sets the suspension ray's direction in world space. This is the chassis- space suspension direction rotated to match the chassis's current orientation.

Parameters

SetEngineForce(number engineForce)

Sets the engine force assigned to this wheel. When the wheel touches the ground, the vehicle turns this force into an impulse to drive the chassis. This setter does not limit the value. A negative value applies force in reverse, and zero means no engine force.

Parameters

  • engineForce number

SetFrictionSlip(number frictionSlip)

Sets this wheel's tire grip setting. Higher values let the tire transfer more force before it starts to slide. Use 0 or greater. No upper limit is enforced. A typical starting value might be around 10.5.

Parameters

  • frictionSlip number

SetGroundBody(Libraries.Interface.Item3D groundBody)

Sets the object beneath this wheel. The vehicle uses it to apply the wheel's suspension and tire forces to the ground. Set this to undefined for a physics step in which the suspension ray hits no ground object.

Parameters

SetInContact(boolean inContact)

Sets whether this wheel is marked as having a suspension ray hit. The vehicle normally sets this from the raycast result, so the next update may replace this value.

Parameters

  • inContact boolean

SetMaxSuspensionForce(number maxSuspensionForce)

Sets the maximum support force from this wheel's suspension. The spring and damper use this cap when pushing the chassis away from the surface at this wheel. Use 0 or greater. The setter does not enforce a range. A typical starting value might be around 6000.

Parameters

  • maxSuspensionForce number

SetMaxSuspensionTravel(number maxSuspensionTravel)

Sets how far, in meters, the suspension can move from its rest length. When the wheel touches the ground, its suspension length is kept between the rest length minus this value and the rest length plus this value. Because the vehicle only finds the ground within the rest length plus the wheel radius, a wheel never extends past its rest length. In practice, this value limits how far the wheel can be pushed up toward the chassis, and it only has an effect when it is smaller than the rest length. This is measured in meters.

Parameters

  • maxSuspensionTravel number: The largest change from the rest length, in meters

SetRadius(number radius)

Sets the radius of the wheel used by the suspension ray and to find the wheel's position from the ground contact point.

Parameters

  • radius number

SetRestLength(number restLength)

Sets the suspension's starting length.

Parameters

  • restLength number

SetRollInfluence(number rollInfluence)

Sets how much sideways tire force can roll the chassis. This scales the height of the force's application point, so lower values reduce chassis roll. Use 0 to 1 for normal behavior, though the setter does not enforce this range. A typical starting value might be around 0.1.

Parameters

  • rollInfluence number

SetSteering(number steering)

Sets this wheel's steering angle in radians. The angle changes the wheel's direction when steering is enabled, which can change the tire force at ground contact. The angle is used as given and is not limited.

Parameters

  • steering number

SetSteeringEnabled(boolean steeringEnabled)

Enables steering to rotate this wheel's axle. When the wheel touches the ground, this can change the direction of its tire friction force.

Parameters

  • steeringEnabled boolean

SetSuspensionChassisPoint(Libraries.Compute.Vector3 suspensionChassisPoint)

Sets the point on the chassis where this wheel's suspension impulse is applied, measured from the chassis's center of mass. The vehicle uses this offset to apply the impulse at the wheel's ground contact point, which can also affect how the chassis turns.

Parameters

SetSuspensionForce(number suspensionForce)

Sets the suspension force value for this wheel. The vehicle normally calculates this value from spring compression and damping during each update. This setter does not clamp it, and the next vehicle update may replace it.

Parameters

  • suspensionForce number

SetSuspensionGroundPoint(Libraries.Compute.Vector3 suspensionGroundPoint)

Sets the ground contact point for this wheel's suspension, measured from the ground body's center of mass. The vehicle uses this offset to find the ground body's velocity at the contact point when calculating suspension motion.

Parameters

SetSuspensionImpulse(Libraries.Compute.Vector3 suspensionImpulse)

Sets the impulse produced by this wheel's suspension for the current physics step. It points along the ground contact's normal, and its size depends on the suspension force and the length of the physics step. The vehicle applies it to the chassis to push it away from the ground.

Parameters

SetSuspensionLength(number suspensionLength)

Sets the suspension's current length. This value changes as the suspension compresses or extends.

Parameters

  • suspensionLength number

SetSuspensionOriginWorldSpace(Libraries.Compute.Vector3 suspensionOriginWorldSpace)

Sets the world-space starting point of the suspension ray. It is calculated from the wheel's connection point on the chassis and moves with the chassis.

Parameters

SetSuspensionStiffness(number suspensionStiffness)

Sets the suspension spring stiffness. Use 0 or greater. There is no upper limit. The default is 5.88, which is Bullet's default.

Parameters

  • suspensionStiffness number

SetTireChassisPoint(Libraries.Compute.Vector3 tireChassisPoint)

Sets the wheel's tire contact point relative to the chassis's center of mass. The vehicle uses this offset to apply tire impulses to the chassis at the contact point, which can also affect how the chassis turns.

Parameters

SetTireForwardImpulse(Libraries.Compute.Vector3 tireForwardImpulse)

Sets this wheel's forward tire impulse for the current physics step. The vehicle applies it to the chassis along the tire's forward direction to drive or slow the vehicle.

Parameters

SetTireGroundPoint(Libraries.Compute.Vector3 tireGroundPoint)

Sets the wheel's tire contact point relative to the ground body's center of mass. The vehicle uses this offset to apply the sideways tire impulse to a movable ground body at the contact point.

Parameters

SetTireImpulse(Libraries.Compute.Vector3 tireImpulse)

Sets the total tire impulse for this wheel during the current physics step. It combines the forward impulse that drives or brakes the vehicle with the sideways impulse that helps the tire grip the ground. The vehicle applies these impulses at the wheel's ground contact point.

Parameters

SetTireSideImpulse(Libraries.Compute.Vector3 tireSideImpulse)

Sets this wheel's sideways tire impulse for the current physics step. The vehicle applies it at the contact point to resist sliding and help steer the chassis.

Parameters

SetToDefaults()

Sets the wheel's suspension and driving settings to common starting values. This resets the tuning, steering, engine, brake, and contact state. It leaves the wheel's position, direction, axle, rest length, and radius unchanged.

SetVisual(Libraries.Interface.Item3D visual)

Sets the Item3D used to show this wheel in the scene. The vehicle updates this item's position and rotation to display the wheel. Before calling this action, orient the item (and any children) as it should look on an unsteered, unspun wheel of a chassis with no rotation. The vehicle uses that pose as the starting point when it applies steering, spin, and the chassis rotation.

Parameters

SetWheelRotation(number wheelRotation)

Sets this wheel's spin angle around its axle, in radians.

Parameters

  • wheelRotation number

Inherited Actions

3 actions from Libraries.Language.Object