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
new RaycastVehicle(options): RaycastVehicle;Defined in: packages/vehicle/src/RaycastVehicle.ts:216
Parameters
| Parameter | Type |
|---|---|
options | RaycastVehicleOptions |
Returns
RaycastVehicle
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
tyres | readonly | "grip" | "slip" | packages/vehicle/src/RaycastVehicle.ts:213 |
wheels | readonly | readonly Wheel[] | packages/vehicle/src/RaycastVehicle.ts:209 |
Methods
fixedUpdate()
fixedUpdate(
body,
timestep,
world
): void;Defined in: packages/vehicle/src/RaycastVehicle.ts:230
Parameters
| Parameter | Type |
|---|---|
body | Body |
timestep | number |
world | World |
Returns
void
Implementation of
forwardSpeed()
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
| Parameter | Type |
|---|---|
body | Body |
Returns
number
