Skip to content

eulerjs API / @eulerjs/vehicle / RaycastVehicle

RaycastVehicle ​

Defined in: packages/vehicle/src/RaycastVehicle.ts:208

Drives a body on wheels, as games usually do: each wheel is a ray down from where its suspension is mounted, finding the ground (any collider, flat or not, still or moving), and a spring and damper between them. Its tyre pushes along the ground with a force that grows with how much it slips, up to its grip times the load on it; beyond that it slides, which is how a car drifts, skids and spins out. What the wheels push on, they push back on: a car pushes a crate it stands on into the ground, and drags it if it drives off it.

Add it to the chassis with body.addBehavior(vehicle), then steer, drive and brake each wheel through wheels. The chassis collides as its own colliders; the wheels only through their rays.

Implements ​

Constructors ​

Constructor ​

ts
new RaycastVehicle(options): RaycastVehicle;

Defined in: packages/vehicle/src/RaycastVehicle.ts:216

Parameters ​

ParameterType
optionsRaycastVehicleOptions

Returns ​

RaycastVehicle

Properties ​

PropertyModifierTypeDefined in
tyresreadonly"grip" | "slip"packages/vehicle/src/RaycastVehicle.ts:213
wheelsreadonlyreadonly Wheel[]packages/vehicle/src/RaycastVehicle.ts:209

Methods ​

fixedUpdate() ​

ts
fixedUpdate(
   body, 
   timestep, 
   world
): void;

Defined in: packages/vehicle/src/RaycastVehicle.ts:230

Parameters ​

ParameterType
bodyBody
timestepnumber
worldWorld

Returns ​

void

Implementation of ​

Behavior.fixedUpdate


forwardSpeed() ​

ts
forwardSpeed(body): number;

Defined in: packages/vehicle/src/RaycastVehicle.ts:226

How fast the body is going forward, in m/s; negative going backward.

Parameters ​

ParameterType
bodyBody

Returns ​

number

Released under the MIT License.