UChaosVehicleMovementComponent

Base component to handle the vehicle simulation for an actor.

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

ChaosVehicles

Header

/Engine/Plugins/Experimental/ChaosVehiclesPlugin/Source/ChaosVehicles/Public/ChaosVehicleMovementComponent.h

Include

#include "ChaosVehicleMovementComponent.h"

Syntax

UCLASS(Abstract,
       HideCategories=(PlanarMovement, "Components|Movement|Planar", Activation, "Components|Activation"))
class UChaosVehicleMovementComponent : public UPawnMovementComponent

Remarks

Base component to handle the vehicle simulation for an actor.

Variables

Name Description

Public variable UProperty Category, EditAnywhere

TArray< FVehicl...

 

Aerofoils

Optional aerofoil setup - can be used for car spoilers or aircraft wings/elevator/rudder

Protected variable

float

 

AngErrorAccumulator

Accumulator for RB replication errors

Public variable UProperty Category, EditAnywhere

bool

 

bEnableCenterOfMassOverride

Enable to override the calculated COM position with your own fixed value - this prevents the vehicle handling changing when the asset changes

Protected variable UProperty Transient

uint8: 1

 

bParkEnabled

Protected variable UProperty Transient

float

 

BrakeInput

Brake output to physics system. Range 0...1.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

FVehicleInputRa...

 

BrakeInputRate

Rate at which input brake can rise and fall.

Protected variable UProperty Transient

uint8: 1

 

bRawGearDownInput

True if the player is holding gear down.

Protected variable UProperty Transient

uint8: 1

 

bRawGearUpInput

True if the player is holding gear up.

Protected variable UProperty Transient

uint8: 1

 

bRawHandbrakeInput

True if the player is holding the handbrake.

Protected variable UProperty Category, EditAnywhere

bool

 

bRequiresControllerForInputs

Bypass the need for a controller in order for the controls to be processed.

Public variable UProperty Category, EditAnywhere

uint8: 1

 

bReverseAsBrake

If true, the brake and reverse controls will behave in a more arcade fashion where holding reverse also functions as brake.

Protected variable UProperty Transient

uint32: 1

 

bWasAvoidanceUpdated

Was avoidance updated in this frame?

Public variable UProperty Category, EditAnywhere, Meta

FVector

 

CenterOfMassOverride

The center of mass override value, this value overrides the calculated COM and the COM offset value in the mesh is also ignored.

Public variable UProperty Category, EditAnywhere, Meta

float

 

ChassisHeight

Chassis height used for drag force computation (cm)

Public variable UProperty Category, EditAnywhere, Meta

float

 

ChassisWidth

Chassis width used for drag force computation (cm)

Public variable

FChaosVehicleAs...

 

CurAsyncInput

Public variable

FChaosVehicleAs...

 

CurAsyncOutput

Public variable

EChaosAsyncVehi...

 

CurAsyncType

Public variable UProperty Transient

float

 

DebugDragMagnitude

Debug drag magnitude last applied.

Public variable UProperty Category, EditAnywhere

float

 

DownforceCoefficient

DownforceCoefficient of the vehicle chassis - force pressing vehicle into ground at speed

Public variable UProperty Transient

float

 

DragArea

Drag area in Meters^2.

Public variable UProperty Category, EditAnywhere

float

 

DragCoefficient

DragCoefficient of the vehicle chassis - force resisting forward motion at speed

Protected variable UProperty Transient

float

 

HandbrakeInput

Handbrake output to physics system. Range 0...1.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

FVehicleInputRa...

 

HandbrakeInputRate

Rate at which input handbrake can rise and fall.

Protected variable UProperty Category, EditAnywhere

float

 

IdleBrakeInput

How much to press the brake when the player has release throttle.

Public variable UProperty Category, EditAnywhere, AdvancedDisplay

FVector

 

InertiaTensorScale

Scales the vehicle's inertia in each direction (forward, right, up)

Public variable UProperty Category, EditAnywhere, Meta

float

 

Mass

Mass to set the vehicle chassis to.

Protected variable

FDelegateHandle

 

MeshOnPhysicsStateChangeHandle

Handle for delegate registered on mesh component

Public variable

FChaosVehicleAs...

 

NextAsyncOutput

Public variable

float

 

OutputInterpAlpha

Public variable

TArray< FAsyncO...

 

OutputsWaitingOn

Protected variable UProperty Transient

float

 

PitchInput

Body Pitch output to physics system. Range -1...1.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

FVehicleInputRa...

 

PitchInputRate

Rate at which input pitch can rise and fall.

Protected variable

TUniquePtr< FPh...

 

PVehicleOutput

Protected variable UProperty Transient

float

 

RawBrakeInput

What the player has the brake set to. Range -1...1.

Protected variable UProperty Transient

float

 

RawPitchInput

What the player has the pitch set to. Range -1...1.

Protected variable UProperty Transient

float

 

RawRollInput

What the player has the roll set to. Range -1...1.

Protected variable UProperty Transient

float

 

RawSteeringInput

What the player has the steering set to. Range -1...1.

Protected variable UProperty Transient

float

 

RawThrottleInput

What the player has the accelerator set to. Range -1...1.

Protected variable UProperty Transient

float

 

RawYawInput

What the player has the yaw set to. Range -1...1.

Protected variable UProperty Transient, Replicated

FVehicleReplica...

 

ReplicatedState

Replicated state of vehicle

Protected variable UProperty Transient

float

 

RollInput

Body Roll output to physics system. Range -1...1.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

FVehicleInputRa...

 

RollInputRate

Rate at which input roll can rise and fall.

Public variable UProperty Category, EditAnywhere, Meta

float

 

SleepSlopeLimit

Option to apply some aggressive sleep logic if slopes up Z is less than this value, i.e value = Cos(SlopeAngle) so 0.866 will sleep up to 30 degree slopes

Public variable UProperty Category, EditAnywhere

float

 

SleepThreshold

Option to apply some aggressive sleep logic, larger number is more agressive, 0 disables

Public variable UProperty Category, EditAnywhere

FVehicleStabili...

 

StabilizeControl

Arcade style control of vehicle

Protected variable UProperty Transient

float

 

SteeringInput

Steering output to physics system. Range -1...1.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

FVehicleInputRa...

 

SteeringInputRate

Rate at which input steering can rise and fall.

Protected variable UProperty Category, EditAnywhere

float

 

StopThreshold

Auto-brake when absolute vehicle forward speed is less than this (cm/s)

Public variable UProperty Category, EditAnywhere

FVehicleTargetR...

 

TargetRotationControl

Arcade style direct control of vehicle rotation via torque force

Protected variable UProperty Transient

float

 

ThrottleInput

Accelerator output to physics system. Range 0...1.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

FVehicleInputRa...

 

ThrottleInputRate

Rate at which input throttle can rise and fall.

Public variable UProperty Category, EditAnywhere

TArray< FVehicl...

 

Thrusters

Optional thruster setup, use one or more as your main engine or as supplementary booster

Public variable UProperty Category, EditAnywhere

FVehicleTorqueC...

 

TorqueControl

Arcade style direct control of vehicle rotation via torque force

Protected variable

Chaos::ETransmi...

 

TransmissionType

Public variable

uint32

 

VehicleSetupTag

Used to recreate the physics if the blueprint changes.

Protected variable

TUniquePtr< UCh...

 

VehicleSimulationPT

Protected variable

FVehicleState

 

VehicleState

Protected variable UProperty Category, EditAnywhere

float

 

WrongDirectionThreshold

Auto-brake when vehicle forward speed is opposite of player input by at least this much (cm/s)

Protected variable UProperty Transient

float

 

YawInput

Body Yaw output to physics system. Range -1...1.

Protected variable UProperty Category, EditAnywhere, AdvancedDisplay

FVehicleInputRa...

 

YawInputRate

Rate at which input yaw can rise and fall.

Constructors

Functions

Name Description

Protected function

float

 

CalcHandbrakeInput()

Compute handbrake input

Protected function

float

 

CalcPitchInput()

Compute pitch input

Protected function

float

 

CalcRollInput()

Compute roll input

Protected function

float

 

CalcSteeringInput()

Compute steering input

Protected function

void

 

CalcThrottleBrakeInput

(
    float& ThrottleOut,
    float& BrakeOut
)

Compute throttle & brake input

Protected function

float

 

CalcThrottleDownInput()

Protected function

float

 

CalcThrottleUpInput()

Compute throttle inputs

Protected function

float

 

CalcYawInput()

Compute yaw input

Public function Virtual Const

bool

 

CanCreateVehicle()

Return true if we are ready to create a vehicle, false if the setup has missing references

Protected function

void

 

ClearAllInput()

Protected function Virtual

void

 

ClearInput()

Clear all interpolated inputs to default values.

Protected function Virtual

void

 

ClearRawInput()

Clear all raw inputs to default values.

Protected function Virtual

void

 

ComputeConstants()

When vehicle is created we want to compute some helper data like drag area, etc....

Protected function Virtual

TUniquePtr< ...

 

CreatePhysicsVehicle()

Protected function Virtual

void

 

CreateVehicle()

Create and setup the Chaos vehicle

Public function UFunction BlueprintCallable, Category

void

 

DecreaseThrottleInput

(
    float ThrottleDelta
)

Decrease the vehicle throttle position [throttle range normalized 0 to 1]

Protected function Virtual

void

 

DrawDebug

(
    UCanvas* Canvas,
    float& YL,
    float& YPos
)

Draw debug text for the wheels and suspension

Protected function

void

 

DrawLine2D

(
    UCanvas* Canvas,
    const FVector2D& StartPos,
    const FVector2D& EndPos,
    FColor Color,
    float Thickness
)

Draw 2D debug line to UI canvas

Public function UFunction BlueprintCallable, Category

void

 

EnableSelfRighting

(
    bool InState
)

Public function

void

 

FinalizeSimCallbackData

Protected function Virtual

void

 

FixupSkeletalMesh()

Skeletal mesh needs some special handling in the vehicle case

Public function Const

void

 

GetBaseSnapshot

(
    FBaseSnapshotData& SnapshotOut
)

Grab a snapshot of the vehicle instance dynamic state

Protected function

FBodyInstanc...

 

GetBodyInstance()

Protected function Const

const FBodyI...

 

GetBodyInstance()

Public function UFunction BlueprintCallable, Category

float

 

GetBrakeInput()

Get the user input for the vehicle brake - can use this to feed control to a connected trailer

Public function Const UFunction BlueprintCallable, Category

int32

 

GetCurrentGear()

Get current gear

Protected function

float

 

GetForwardAcceleration()

Public function Const UFunction BlueprintCallable, Category

float

 

GetForwardSpeed()

How fast the vehicle is moving forward

Public function Const UFunction BlueprintCallable, Category

float

 

GetForwardSpeedMPH()

How fast the vehicle is moving forward

Public function Const UFunction BlueprintCallable, Category

bool

 

GetHandbrakeInput()

Get the user input for the vehicle handbrake - can use this to feed control to a connected trailer

Protected function Const

UMeshCompone...

 

GetMesh()

Get the mesh this vehicle is tied to

Protected function

USkeletalMes...

 

GetSkeletalMesh()

Get Mesh cast as USkeletalMeshComponent, may return null if cast fails

Protected function

UStaticMeshC...

 

GetStaticMesh()

Get Mesh cast as UStaticMeshComponent, may return null if cast fails

Public function UFunction BlueprintCallable, Category

float

 

GetSteeringInput()

Get the user input for the vehicle steering - can use this to feed control to a connected trailer

Public function Virtual

float

 

GetSuspensionOffset

(
    int WheelIndex
)

Public function Const UFunction BlueprintCallable, Category

int32

 

GetTargetGear()

Get target gear

Public function UFunction BlueprintCallable, Category

float

 

GetThrottleInput()

Get the user input for the vehicle throttle - can use this to feed control to a connected trailer

Public function Const UFunction BlueprintCallable, Category

bool

 

GetUseAutoGears()

Are gears being changed automatically?

Public function UFunction BlueprintCallable, Category

void

 

IncreaseThrottleInput

(
    float ThrottleDelta
)

Increase the vehicle throttle position [throttle range normalized 0 to 1]

Public function Const UFunction BlueprintCallable, Category

bool

 

IsParked()

Is the vehicle in park mode

Public function Const

FVector

 

LocateBoneOffset

(
    const FName InBoneName,
    const FVector& InExtraOffset
)

Location local coordinates of named bone in skeleton, apply additional offset or just use offset if no bone located

Public function Virtual

void

 

ParallelUpdate

(
    float DeltaSeconds
)

Get output data from Physics Thread.

Public function

TUniquePtr< ...

 

PhysicsVehicleOutput()

Protected function Virtual

void

 

PostSetupVehicle()

Do some final setup after the Chaos vehicle gets created

Public function Virtual

void

 

PreTickGT

(
    float DeltaTime
)

Updates the vehicle tuning and other state such as user input.

Protected function Virtual

void

 

ProcessSleeping

(
    const FControlInputs& ControlInput...
)

Option to aggressively sleep the vehicle

Public function UFunction BlueprintCallable, Category

void

 

ResetVehicle()

Reset some vehicle state - call this if you are say creating pool of vehicles that get reused and you don't want to carry over the previous state

Public function Virtual

void

 

ResetVehicleState()

Protected function UFunction Server, Reliable withvalidation

void

 

ServerUpdateState

(
    float InSteeringInput,
    float InThrottleInput,
    float InBrakeInput,
    float InHandbrakeInput,
    int32 InCurrentGear,
    float InRollInput,
    float InPitchInput,
    float InYawInput
)

Pass current state to server

Public function

void

 

SetBaseSnapshot

(
    const FBaseSnapshotData& SnapshotI...
)

Set snapshot of vehicle instance dynamic state

Public function UFunction BlueprintCallable, Category

void

 

SetBrakeInput

(
    float Brake
)

Set the user input for the vehicle Brake [range 0 to 1]

Public function UFunction BlueprintCallable, Category

void

 

SetChangeDownInput

(
    bool bNewGearDown
)

Set the user input for gear down

Public function UFunction BlueprintCallable, Category

void

 

SetChangeUpInput

(
    bool bNewGearUp
)

Set the user input for gear up

Public function

TUniquePtr< ...

 

SetCurrentAsyncInputOutput

(
    int32 InputIdx,
    FChaosVehicleManagerAsyncOutput...,
    FChaosVehicleManagerAsyncOutput...,
    float Alpha,
    int32 VehicleManagerTimestamp
)

Public function

void

 

SetCurrentAsyncInputOutputInternal

(
    FChaosVehicleAsyncInput* CurIn...,
    int32 InputIdx,
    FChaosVehicleManagerAsyncOutput...,
    int32 VehicleManagerTimestamp
)

Public function

void

 

SetCurrentAsyncInputOutputInternal

(
    FChaosVehicleAsyncInput* CurIn...,
    int32 InputIdx,
    FChaosVehicleManagerAsyncOutput...,
    FChaosVehicleManagerAsyncOutput...,
    float Alpha,
    int32 VehicleManagerTimestamp
)

Public function UFunction BlueprintCallable, Category

void

 

SetHandbrakeInput

(
    bool bNewHandbrake
)

Set the user input for handbrake

Public function Virtual

void

 

SetOverrideController

(
    AController* OverrideControlle...
)

Allow the player controller of a different pawn to control this vehicle

Public function UFunction BlueprintCallable, Category

void

 

SetParked

(
    bool bParked
)

Set the vehicle in park mode

Public function UFunction BlueprintCallable, Category

void

 

SetPitchInput

(
    float Pitch
)

Set the user input for the vehicle pitch [range -1 to 1]

Public function UFunction BlueprintCallable, Category

void

 

SetRequiresControllerForInputs

(
    bool bRequiresController
)

Set the flag that determines whether a controller is required to set control inputs

Public function UFunction BlueprintCallable, Category

void

 

SetRollInput

(
    float Roll
)

Set the user input for the vehicle roll [range -1 to 1]

Public function UFunction BlueprintCallable, Category

void

 

SetSleeping

(
    bool bEnableSleep
)

Set the vehicle sleeping (bEnableSleep=true) or wake it up (bEnableSleep=false)

Public function UFunction BlueprintCallable, Category

void

 

SetSteeringInput

(
    float Steering
)

Set the user input for the vehicle steering [range -1 to 1]

Public function UFunction BlueprintCallable, Category

void

 

SetTargetGear

(
    int32 GearNum,
    bool bImmediate
)

Set the user input for gear (-1 reverse, 0 neutral, 1+ forward)

Public function UFunction BlueprintCallable, Category

void

 

SetThrottleInput

(
    float Throttle
)

Set the user input for the vehicle throttle [range 0 to 1]

Protected function Virtual

void

 

SetupVehicle

Allocate and setup the Chaos vehicle

Protected function Virtual

void

 

SetupVehicleMass()

Adjust the Chaos Physics mass

Public function UFunction BlueprintCallable, Category

void

 

SetUseAutomaticGears

(
    bool bUseAuto
)

Set the flag that will be used to select auto-gears

Public function UFunction BlueprintCallable, Category

void

 

SetYawInput

(
    float Yaw
)

Set the user input for the vehicle yaw [range -1 to 1]

Protected function

void

 

ShowDebugInfo

(
    AHUD* HUD,
    UCanvas* Canvas,
    const FDebugDisplayInfo& DisplayIn...,
    float& YL,
    float& YPos
)

Public function Virtual

void

 

Update

(
    float DeltaTime
)

Protected function

void

 

UpdateMassProperties

(
    FBodyInstance* BI
)

Protected function Virtual

void

 

UpdateState

(
    float DeltaTime
)

Read current state for simulation

Overridden from UPawnMovementComponent

Name Description

Protected function Virtual Const

AController ...

 

GetController()

Get our controller

Overridden from UMovementComponent

Name Description

Public function Virtual

void

 

SetUpdatedComponent

(
    USceneComponent* NewUpdatedCom...
)

Overridden to allow registration with components NOT owned by a Pawn.

Public function Virtual

void

 

StopMovementImmediately()

Stops movement immediately (zeroes velocity, usually zeros acceleration for components with acceleration).

Overridden from UActorComponent

Name Description

Public function Virtual Const

bool

 

HasValidPhysicsState()

Returns true if the physics state exists

Public function Virtual

void

 

OnCreatePhysicsState()

Used to create any physics engine information for this component

Public function Virtual

void

 

OnDestroyPhysicsState()

Used to shut down and physics engine structure for this component

Public function Virtual Const

bool

 

ShouldCreatePhysicsState()

Return true if it's suitable to create a physics representation of the vehicle at this time

Overridden from UObject

Name Description

Public function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

End UObject interface Respond to a property change in editor

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

UObject interface

Classes

Name

Description

Public struct

FAsyncOutputWrapper