Skip to content

Class Vehicle

Namespace: Apogee.Physics
Assembly: Apogee.Physics.dll

A vehicle on a dynamic body: wheels with suspension and tires, or tracks, an engine and a clutch (Jolt's VehicleConstraint). The game owns the gearbox: it sets (the signed overall ratio it wants, 0 for neutral) and in the signal, which runs before each physics step, together with the driver's inputs, and the vehicle gives them to Jolt. Make one with .

public sealed class Vehicle : EngineObject

Inheritance

object ← EngineObject ← Vehicle

Inherited Members

EngineObject.IsAdopted, EngineObject.Handle, EngineObject.IsDestroyed, EngineObject.Class, EngineObject.Adopt(), EngineObject.TryGet(SlotHandle, out EngineObject), EngineObject.Destroy(), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks

A road or tracked vehicle on Jolt's wheeled and tracked VehicleConstraint, tuned for heavy vehicles. Differences from Jolt's own: its transmission stays in manual mode with one forward and one reverse gear whose ratio is rewritten each step; wheels at one axle share a differential whose ratio goes with the wheel size; the wheels of a vehicle with no powered wheel (a trailer) stay in neutral; and the steered wheels turn about one center (Ackermann).

Properties

Brake

public float Brake { get; set; }

Property Value

float

BrakeCapacity

What all the brakes give together, in N·m.

public float BrakeCapacity { get; }

Property Value

float

Class

What the registry knows about this object's class.

public override ClassInfo Class { get; }

Property Value

ClassInfo

Clutch

How far the clutch is engaged: 0 drives nothing, 1 is fully engaged. Set it in .

public float Clutch { get; set; }

Property Value

float

DriveRatio

The overall ratio between engine and wheels the game drives through, signed: negative reverses; 0 is neutral. Set it in .

public float DriveRatio { get; set; }

Property Value

float

EngineLoad

The throttle that reached the engine, 0 to 1.

public float EngineLoad { get; }

Property Value

float

EnginePeakPowerRpm

The rpm where the engine's power (torque times rpm) peaks, from its curve.

public float EnginePeakPowerRpm { get; }

Property Value

float

EngineRpm

public float EngineRpm { get; }

Property Value

float

EngineTorque

The torque the engine gives at the throttle that reached it, in N·m.

public float EngineTorque { get; }

Property Value

float

Entity

The entity of the vehicle's body.

public Entity Entity { get; }

Property Value

Entity

Forward

Throttle: -1 to 1 (negative backs up in a gearbox that reverses by throttle; the usual gearbox uses 's sign).

public float Forward { get; set; }

Property Value

float

GearRatio

The gear ratio the transmission is in now.

public float GearRatio { get; }

Property Value

float

Handbrake

public float Handbrake { get; set; }

Property Value

float

IsReady

Whether the vehicle is working (its body exists and the wheels were built).

public bool IsReady { get; }

Property Value

bool

SpeedKmh

How fast it moves along its forward axis, in km/h (negative backing up).

public float SpeedKmh { get; }

Property Value

float

Steering

-1 to 1: positive turns toward +X (the vehicle's left, in its +Z-forward space), negative toward -X.

public float Steering { get; set; }

Property Value

float

Stepping

Emitted before each fixed step with its length, before the inputs reach Jolt: the game's driving logic (its gearbox, assists, ABS) belongs here.

public Signal<float> Stepping { get; }

Property Value

Signal<float>

WheelCount

How many wheels it has.

public int WheelCount { get; }

Property Value

int

Methods

GetBrakeFactor(int)

public float GetBrakeFactor(int index)

Parameters

index int

Returns

float

GetWheelCompression(int)

How far the suspension is compressed, 0 (extended) to 1.

public float GetWheelCompression(int index)

Parameters

index int

Returns

float

GetWheelContact(int)

public bool GetWheelContact(int index)

Parameters

index int

Returns

bool

GetWheelContactEntity(int)

The entity of the body the wheel stands on, or 0.

public Entity GetWheelContactEntity(int index)

Parameters

index int

Returns

Entity

GetWheelContactNormal(int)

public Vector3 GetWheelContactNormal(int index)

Parameters

index int

Returns

Vector3

GetWheelContactPoint(int)

The point where the wheel touches the ground (the world's origin if it does not).

public Double3 GetWheelContactPoint(int index)

Parameters

index int

Returns

Double3

GetWheelReadings()

Four numbers for each wheel, the ones the driving assists need: 1 if it touches the ground (else 0), its angular velocity in rad/s, the load it carries in newtons (its suspension's force) and the grip of its tire (0 for a track's wheel).

public float[] GetWheelReadings()

Returns

float[]

GetWheelRpm(int)

The wheel's rotation speed in revolutions per minute.

public float GetWheelRpm(int index)

Parameters

index int

Returns

float

GetWheelSteerDegrees(int)

How far the wheel is turned about its steering axis, in degrees (positive toward +X, like ).

public float GetWheelSteerDegrees(int index)

Parameters

index int

Returns

float

OnDestroyed()

protected override void OnDestroyed()

SetBrakeFactor(int, float)

Scales one wheel's brake torque for the next steps: 0 releases it, 1 is full. An ABS sets it every step.

public void SetBrakeFactor(int index, float factor)

Parameters

index int

factor float