Physics · class

Vehicle

Explained in Your first game, Rigid bodies.

class Vehicle
import { Vehicle } from '@driftengine/physics';

Constructor

new

constructor(chassis: number, options: VehicleOptions)
ParameterTypeDescription
chassisnumber
optionsVehicleOptions

Properties

NameTypeDescription
chassisreadonlynumber
wheelCountreadonlynumber
groundedreadonlyUint8ArrayWhether each wheel found ground on the last update.
compressionreadonlyFloat32ArrayHow far each wheel's suspension is compressed, in metres.
contactreadonlyFloat32ArrayWhere each wheel's contact is, xyz-packed. Meaningful where grounded.

Methods

update

update(world: PhysicsWorld, dt: number, input: VehicleInput): void

Advance the vehicle one fixed tick. Call before world.step.

ParameterTypeDescription
worldPhysicsWorld
dtnumber
inputVehicleInput