UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SteeringSystem.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "HAL/Platform.h"
6#include "Math/Vector2D.h"
7#include "SteeringUtility.h"
9#include "VehicleUtility.h"
10
11#if VEHICLE_DEBUGGING_ENABLED
13#endif
14
15namespace Chaos
16{
17
18 enum class ESteerType : uint8
19 {
23 };
24
26 {
28 : SteeringType(ESteerType::AngleRatio)
29 , AngleRatio(0.7f)
30 , TrackWidth(1.8f)
31 , WheelBase(3.8f)
32 {}
33
36
38 float WheelBase;
39
41
43 };
44
45 class CHAOSVEHICLESCORE_API FAckermannSim : public TVehicleSystem<FSimpleSteeringConfig>
46 {
47 public:
48
50
51 void GetLeftHingeLocations(FVector2D& OutC1, FVector2D& OutP, FVector2D& OutC2);
52
53 void GetRightHingeLocations(FVector2D& OutC1, FVector2D& OutP, FVector2D& OutC2);
54
55 void CalculateAkermannAngle(float Input, float& OutSteerLeft, float& OutSteerRight);
56
58 {
59 return MaxAckermanAngle;
60 }
61
62 private:
63 FVector2D C1;
64 FVector2D C2;
65 float R1;
66 float R2;
67 float SteerInputScaling;
68 float MaxAckermanAngle;
69
70 FVector2D LeftRodPt, RightRodPt;
71 FVector2D LeftPivot;
72 FVector2D RightPivot;
73
74 float RestAngle;
75
76 };
77
78 class CHAOSVEHICLESCORE_API FSimpleSteeringSim : public TVehicleSystem<FSimpleSteeringConfig>
79 {
80 public:
86
88 {
89 return Setup().SpeedVsSteeringCurve.EvaluateY(VelocityMPH);
90 }
91
92 float GetSteeringAngle(float InNormSteering, float MaxSteeringAngle, float WheelSide)
93 {
94 float OutSteeringAngle = 0.f;
95
96 switch (Setup().SteeringType)
97 {
98 case ESteerType::AngleRatio:
99 {
100 bool OutsideWheel = (InNormSteering * WheelSide) > 0.f;
101 OutSteeringAngle = InNormSteering * (OutsideWheel ? MaxSteeringAngle : MaxSteeringAngle * Setup().AngleRatio);
102
103 }
104 break;
105
106 case ESteerType::Ackermann:
107 {
108 float SteerLHS; float SteerRHS;
109
110 Ackermann.CalculateAkermannAngle(-InNormSteering, SteerLHS, SteerRHS);
111
113 OutSteeringAngle *= (MaxSteeringAngle / Ackermann.GetMaxAckermanAngle());
114 }
115 break;
116
117 default:
118 case ESteerType::SingleAngle:
119 {
120 OutSteeringAngle = MaxSteeringAngle * InNormSteering;
121 }
122 break;
123
124 }
125
126 return OutSteeringAngle;
127 }
129 };
130
131} // namespace Chaos
132
133#if VEHICLE_DEBUGGING_ENABLED
135#endif
#define UE_ENABLE_OPTIMIZATION
Definition CoreMiscDefines.h:60
#define UE_DISABLE_OPTIMIZATION
Definition CoreMiscDefines.h:59
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition SteeringSystem.h:46
float GetMaxAckermanAngle()
Definition SteeringSystem.h:57
Definition VehicleUtility.h:89
Definition SteeringSystem.h:79
FSimpleSteeringSim(const FSimpleSteeringConfig *SetupIn)
Definition SteeringSystem.h:81
float GetSteeringAngle(float InNormSteering, float MaxSteeringAngle, float WheelSide)
Definition SteeringSystem.h:92
float GetSteeringFromVelocity(float VelocityMPH)
Definition SteeringSystem.h:87
FAckermannSim Ackermann
Definition SteeringSystem.h:128
Definition VehicleSystemTemplate.h:13
Definition SkeletalMeshComponent.h:307
ESteerType
Definition SteeringSystem.h:19
Definition SteeringSystem.h:26
float AngleRatio
Definition SteeringSystem.h:35
float MaxSteeringAngle
Definition SteeringSystem.h:40
ESteerType SteeringType
Definition SteeringSystem.h:34
FSimpleSteeringConfig()
Definition SteeringSystem.h:27
float TrackWidth
Definition SteeringSystem.h:37
float WheelBase
Definition SteeringSystem.h:38
FGraph SpeedVsSteeringCurve
Definition SteeringSystem.h:42