Class WheeledVehicle
Representation of the car vehicle that uses wheels. Built on top of the RigidBody with collider representing its chassis shape and wheels.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Physics/Actors/WheeledVehicle.h
Syntax
public class WheeledVehicle : public RigidBody
Fields
UseAnalogSteering
If checked, the vehicle driving and steering inputs will be used as analog values (from gamepad), otherwise will be used as digital input (from keyboard).
Declaration
public bool UseAnalogSteering = false
Field Value
bool
|
UseReverseAsBrake
If checked, the negative throttle value will be used as brake and reverse to behave in a more arcade style where holding reverse also functions as brake. Disable it for more realistic driving controls.
Declaration
public bool UseReverseAsBrake = true
Field Value
bool
|
Methods
BeginPlay(SceneBeginData* data)
Called when adding object to the game.
Declaration
protected virtual void BeginPlay(SceneBeginData* data) override
Parameters
SceneBeginData
data
The initialization data (e.g. used to collect joints to link after begin). |
Overrides
ClearInput()
Clears all the vehicle control inputs to the default values (throttle, steering, breaks).
Declaration
public void ClearInput()
Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
Deserializes object from the input stream.
Declaration
public virtual void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override
Parameters
DeserializeStream
stream
The input stream. |
ISerializeModifier
modifier
The deserialization modifier object. Always valid. |
Overrides
EndPlay()
Called when removing object from the game.
Declaration
protected virtual void EndPlay() override
Overrides
GetAntiRollBars()
Gets axles anti roll bars.
Declaration
public Array<AntiRollBar> GetAntiRollBars() const
Returns
Array<AntiRollBar>
|
GetCurrentGear()
Gets the current gear number. Neutral gears is 0, reverse gears is -1, forward gears are 1 and higher.
Declaration
public int32 GetCurrentGear() const
Returns
int32
|
GetDifferential()
Gets the vehicle differential settings.
Declaration
public DifferentialSettings GetDifferential() const
Returns
DifferentialSettings
|
GetDriveControl()
Gets the vehicle drive control settings.
Declaration
public DriveControlSettings GetDriveControl() const
Returns
DriveControlSettings
|
GetDriveType()
Gets the vehicle driving model type.
Declaration
public DriveTypes GetDriveType() const
Returns
DriveTypes
|
GetEngine()
Gets the vehicle engine settings.
Declaration
public EngineSettings GetEngine() const
Returns
EngineSettings
|
GetEngineRotationSpeed()
Gets the current engine rotation speed (Revolutions Per Minute is the number of turns in one minute).
Declaration
public float GetEngineRotationSpeed() const
Returns
float
|
GetForwardSpeed()
Gets the current forward vehicle movement speed (along forward vector of the actor transform).
Declaration
public float GetForwardSpeed() const
Returns
float
|
GetGearbox()
Gets the vehicle gearbox settings.
Declaration
public GearboxSettings GetGearbox() const
Returns
GearboxSettings
|
GetSidewaysSpeed()
Gets the current sideways vehicle movement speed (along right vector of the actor transform).
Declaration
public float GetSidewaysSpeed() const
Returns
float
|
GetTargetGear()
Gets the target gear number. Neutral gears is 0, reverse gears is -1, forward gears are 1 and higher.
Declaration
public int32 GetTargetGear() const
Returns
int32
|
GetThrottle()
Get the vehicle throttle. It is the analog accelerator pedal value in range (0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
Declaration
public float GetThrottle()
Returns
float
The vehicle throttle. |
GetWheels()
Gets the vehicle wheels settings.
Declaration
public Array<Wheel> GetWheels() const
Returns
Array<Wheel>
|
GetWheelState(int32 index, WheelState& result)
Gets the current state of the wheel.
Declaration
public void GetWheelState(int32 index, WheelState& result)
Parameters
int32
index
The index of the wheel. |
WheelState
result
The current state. |
OnActiveInTreeChanged()
Called when actor active in tree state gets changed.
Declaration
public virtual void OnActiveInTreeChanged() override
Overrides
OnColliderChanged(Collider* c)
Declaration
public virtual void OnColliderChanged(Collider* c) override
Parameters
Collider
c
|
Overrides
OnDebugDrawSelected()
Draws debug shapes for the selected actor and all child scripts.
Declaration
public virtual void OnDebugDrawSelected() override
Overrides
OnPhysicsSceneChanged(PhysicsScene* previous)
Declaration
protected virtual void OnPhysicsSceneChanged(PhysicsScene* previous) override
Parameters
PhysicsScene
previous
|
Overrides
OnTransformChanged()
Called when actor transform gets changed.
Declaration
protected virtual void OnTransformChanged() override
Overrides
Serialize(SerializeStream& stream, const void* otherObj)
Serializes object to the output stream compared to the values of the other object instance (eg. default class object). If other object is null then serialize all properties.
Declaration
public virtual void Serialize(SerializeStream& stream, const void* otherObj) override
Parameters
SerializeStream
stream
The output stream. |
void
otherObj
The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties. |
Overrides
SetAntiRollBars(const Array<AntiRollBar>& value)
Sets axles anti roll bars to increase vehicle stability.
Declaration
public void SetAntiRollBars(const Array<AntiRollBar>& value)
Parameters
Array<AntiRollBar>
value
|
SetBrake(float value)
Sets the input for vehicle brakes. Brake is the analog brake pedal value in range (0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
Declaration
public void SetBrake(float value)
Parameters
float
value
The value (0,1 range). |
SetCurrentGear(int32 value)
Sets the current gear number. The gear change is instant. Neutral gears is 0, reverse gears is -1, forward gears are 1 and higher.
Declaration
public void SetCurrentGear(int32 value)
Parameters
int32
value
|
SetDifferential(const DifferentialSettings& value)
Sets the vehicle differential settings.
Declaration
public void SetDifferential(const DifferentialSettings& value)
Parameters
DifferentialSettings
value
|
SetDriveControl(DriveControlSettings value)
Sets the vehicle drive control settings.
Declaration
public void SetDriveControl(DriveControlSettings value)
Parameters
DriveControlSettings
value
|
SetDriveType(DriveTypes value)
Sets the vehicle driving model type.
Declaration
public void SetDriveType(DriveTypes value)
Parameters
DriveTypes
value
|
SetEngine(const EngineSettings& value)
Sets the vehicle engine settings.
Declaration
public void SetEngine(const EngineSettings& value)
Parameters
EngineSettings
value
|
SetGearbox(const GearboxSettings& value)
Sets the vehicle gearbox settings.
Declaration
public void SetGearbox(const GearboxSettings& value)
Parameters
GearboxSettings
value
|
SetHandbrake(float value)
Sets the input for vehicle handbrake. Handbrake is the analog handbrake value in range (0,1) where 1 represents the handbrake fully engaged and 0 represents the handbrake in its rest state.
Declaration
public void SetHandbrake(float value)
Parameters
float
value
The value (0,1 range). |
SetSteering(float value)
Sets the input for vehicle steering. Steer is the analog steer value in range (-1,1) where -1 represents the steering wheel at left lock and +1 represents the steering wheel at right lock.
Declaration
public void SetSteering(float value)
Parameters
float
value
The value (-1,1 range). |
SetTankLeftBrake(float value)
Sets the input for tank brakes the left track. Brake is the analog brake pedal value in range (0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
Declaration
public void SetTankLeftBrake(float value)
Parameters
float
value
The value (0,1 range). |
SetTankLeftThrottle(float value)
Sets the input for tank left track throttle. It is the analog accelerator pedal value in range (-1,1) where 1 represents the pedal fully pressed to move to forward, 0 to represents the pedal in its rest state and -1 represents the pedal fully pressed to move to backward. The track direction will be inverted if the vehicle current gear is rear.
Declaration
public void SetTankLeftThrottle(float value)
Parameters
float
value
The value (-1,1 range). |
SetTankRightBrake(float value)
Sets the input for tank brakes the right track. Brake is the analog brake pedal value in range (0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
Declaration
public void SetTankRightBrake(float value)
Parameters
float
value
The value (0,1 range). |
SetTankRightThrottle(float value)
Sets the input for tank right track throttle. It is the analog accelerator pedal value in range (-1,1) where 1 represents the pedal fully pressed to move to forward, 0 to represents the pedal in its rest state and -1 represents the pedal fully pressed to move to backward. The track direction will be inverted if the vehicle current gear is rear.
Declaration
public void SetTankRightThrottle(float value)
Parameters
float
value
The value (-1,1 range). |
SetTargetGear(int32 value)
Sets the target gear number. Gearbox will change the current gear to the target. Neutral gears is 0, reverse gears is -1, forward gears are 1 and higher.
Declaration
public void SetTargetGear(int32 value)
Parameters
int32
value
|
SetThrottle(float value)
Sets the input for vehicle throttle. It is the analog accelerator pedal value in range (0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
Declaration
public void SetThrottle(float value)
Parameters
float
value
The value (-1,1 range). When using UseReverseAsBrake it can be negative and will be used as brake and backward driving. |
Setup()
Rebuilds the vehicle. Call it after modifying vehicle settings (eg. engine options).
Declaration
public void Setup()
SetWheels(const Array<Wheel>& value)
Sets the vehicle wheels settings.
Declaration
public void SetWheels(const Array<Wheel>& value)
Parameters
Array<Wheel>
value
|