UChaosVehicleMovementComponent

Base component to handle the vehicle simulation for an actor.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

ChaosVehicles

Header

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

Include

#include "ChaosVehicleMovementComponent.h"

Syntax

[UCLASS](Programming/UnrealArchitecture/Reference/Classes#classdeclaration)(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

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.

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

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 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

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< Cha...

 

PVehicle

#todo: this isn't very configurable

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

Public variable

uint32

 

VehicleSetupTag

Used to recreate the physics if the blueprint changes.

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

Name Description

Public function

UChaosVehicleMovementComponent

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Protected function

void

 

AddForce

(
    const FVector& Force,
    bool bAllowSubstepping,
    bool bAccelChange
)

Add a force to this vehicle

Protected function

void

 

AddForceAtPosition

(
    const FVector& Force,
    const FVector& Position,
    bool bAllowSubstepping,
    bool bIsLocalForce
)

Add a force at a particular position (world space when bIsLocalForce = false, body space otherwise)

Protected function

void

 

AddImpulse

(
    const FVector& Impulse,
    bool bVelChange
)

Add an impulse to this vehicle

Protected function

void

 

AddImpulseAtPosition

(
    const FVector& Impulse,
    const FVector& Position
)

Add an impulse to this vehicle and a particular world position

Protected function

void

 

AddTorqueInRadians

(
    const FVector& Torque,
    bool bAllowSubstepping,
    bool bAccelChange
)

Add a torque to this vehicle

Protected function Virtual

void

 

ApplyAerodynamics

(
    float DeltaTime
)

Apply aerodynamic forces to vehicle body

Protected function Virtual

void

 

ApplyAerofoilForces

(
    float DeltaTime
)

Apply Aerofoil forces to vehicle body

Protected function Virtual

void

 

ApplyInput

(
    float DeltaTime
)

Pass control Input to the vehicle systems

Protected function Virtual

void

 

ApplyThrustForces

(
    float DeltaTime
)

Apply Thruster forces to vehicle body

Protected function Virtual

void

 

ApplyTorqueControl

(
    float DeltaTime
)

Apply direct control over vehicle body rotation

Protected function

float

 

CalcBrakeInput()

Compute brake input

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

float

 

CalcThrottleDownInput()

Protected function Virtual

float

 

CalcThrottleInput()

Compute throttle inputs

Protected function

float

 

CalcThrottleUpInput()

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

Public function Virtual Const

bool

 

CanSimulate()

Are enough vehicle systems specified such that physics vehicle simulation is possible

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

void

 

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 Virtual

void

 

DrawDebug3D()

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
)

Protected function Virtual

void

 

FixupSkeletalMesh()

Skeletal mesh needs some special handling in the vehicle case

Protected function

FBodyInstanc...

 

GetBodyInstance()

Protected function Const

AController ...

 

GetController()

Get our controller

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

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 Const UFunction BlueprintCallable, Category

int32

 

GetTargetGear()

Get target gear

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

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

TUniquePtr< ...

 

PhysicsVehicle()

Protected function Virtual

void

 

PostSetupVehicle()

Do some final setup after the Chaos vehicle gets created

Public function Virtual

void

 

PreTick

(
    float DeltaTime
)

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

Protected function Virtual

void

 

ProcessSleeping()

Option to aggressively sleep the vehicle

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 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 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

 

SetPitchInput

(
    float Pitch
)

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

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

 

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

 

TickVehicle

(
    float DeltaTime
)

Tick this vehicle sim right before input is sent to the vehicle system

Protected function

void

 

UpdateMassProperties

(
    FBodyInstance* BI
)

Protected function Virtual

void

 

UpdateSimulation

(
    float DeltaTime
)

Advance the vehicle simulation

Protected function Virtual

void

 

UpdateState

(
    float DeltaTime
)

Read current state for simulation

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

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss