8#include "Components/BoxComponent.h"
9#include "Engine/CollisionProfile.h"
11#include "Rendering/SkeletalMeshRenderData.h"
12#include "UObject/UObjectGlobals.h"
13#include "DrawDebugHelpers.h"
14#include "Kismet/KismetSystemLibrary.h"
16#include "PhysXPublic.h"
17#include "PhysXVehicleManager.h"
18#include "TireConfig.h"
19#include "VehicleWheel.h"
36 Super(ObjectInitializer)
38 VehicleBounds = CreateDefaultSubobject<UBoxComponent>(TEXT(
"VehicleBounds"));
41 VehicleBounds->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
43 VelocityControl = CreateDefaultSubobject<UVehicleVelocityControl>(TEXT(
"VelocityControl"));
46 GetVehicleMovementComponent()->bReverseAsBrake =
false;
47 BaseMovementComponent = CreateDefaultSubobject<UBaseCarlaMovementComponent>(TEXT(
"BaseMovementComponent"));
55 #ifdef WHEEL_SWEEP_ENABLED
71 UE_LOG(LogCarla, Warning, TEXT(
"Error: Sweep for wheel collision is not available. \
72 Make sure you have installed the required patch.") );
81 #ifdef WHEEL_SWEEP_ENABLED
92 UE_LOG(LogCarla, Warning, TEXT(
"Error: Sweep for wheel collision is not available. \
93 Make sure you have installed the required patch.") );
105 FTransform ActorInverseTransform = GetActorTransform().Inverse();
111 UPhysicsConstraintComponent* ConstraintComponent =
112 Cast<UPhysicsConstraintComponent>(GetDefaultSubobjectByName(ComponentName));
113 if (ConstraintComponent)
116 GetDefaultSubobjectByName(ConstraintComponent->ComponentName1.ComponentName));
119 UE_LOG(LogCarla, Warning, TEXT(
"Door name: %s"), *(DoorComponent->GetName()));
120 FTransform ComponentWorldTransform = DoorComponent->GetComponentTransform();
121 FTransform RelativeTransform = ComponentWorldTransform * ActorInverseTransform;
125 ConstraintComponent->TermComponentConstraint();
129 UE_LOG(LogCarla, Error, TEXT(
"Missing component for constraint: %s"), *(ConstraintComponent->GetName()));
137 TArray<UPhysicsConstraintComponent*> Constraints;
138 GetComponents(Constraints);
139 for (UPhysicsConstraintComponent* Constraint : Constraints)
144 GetDefaultSubobjectByName(Constraint->ComponentName1.ComponentName));
146 GetDefaultSubobjectByName(Constraint->ComponentName2.ComponentName));
147 if (CollisionDisabledComponent1)
151 if (CollisionDisabledComponent2)
158 float FrictionScale = 3.5f;
160 UWheeledVehicleMovementComponent* MovementComponent = GetVehicleMovementComponent();
162 if (MovementComponent)
164 check(MovementComponent !=
nullptr);
169 TArray<float> OriginalFrictions;
170 OriginalFrictions.Init(FrictionScale, MovementComponent->Wheels.Num());
175 TArray<AActor *> OverlapActors;
176 GetOverlappingActors(OverlapActors, AFrictionTrigger::StaticClass());
177 for (
const auto &
Actor : OverlapActors)
182 FrictionScale = FrictionTrigger->
Friction;
187 TArray<FWheelSetup> NewWheelSetups = MovementComponent->WheelSetups;
188 for (
const auto &WheelSetup : NewWheelSetups)
190 UVehicleWheel *Wheel = WheelSetup.WheelClass.GetDefaultObject();
191 check(Wheel !=
nullptr);
194 MovementComponent->WheelSetups = NewWheelSetups;
214 const FTransform GlobalTransform = GetActorTransform();
216 FBox Box = FBox(-Vec, Vec);
217 const FTransform NonScaledTransform(GlobalTransform.GetRotation(), GlobalTransform.GetLocation(), {1.0f, 1.0f, 1.0f});
242 const FQuat& Rotation = GetActorQuat();
243 DrawDebugBox(GetWorld(), Center, Extent, Rotation, FColor::Magenta,
false, 0.0f, 0, 5.0f);
261 const FTransform& CompToWorldTransform = RootComponent->GetComponentTransform();
262 const FRotator Rotation = CompToWorldTransform.GetRotation().Rotator();
263 const FVector Translation = CompToWorldTransform.GetLocation();
264 const FVector Scale = CompToWorldTransform.GetScale3D();
272 FTransform Transform;
309 const auto &Wheels = GetVehicleMovementComponent()->Wheels;
310 check(Wheels.Num() > 0);
311 const auto *FrontWheel = Wheels[0];
312 check(FrontWheel !=
nullptr);
313 return FrontWheel->SteerAngle;
371 UWheeledVehicleMovementComponent* Movement = GetVehicleMovement();
372 TArray<float> WheelsFrictionScale;
375 check(Movement !=
nullptr);
377 for (
auto &Wheel : Movement->Wheels)
379 WheelsFrictionScale.Add(Wheel->TireConfig->GetFrictionScale());
382 return WheelsFrictionScale;
388 UWheeledVehicleMovementComponent* Movement = GetVehicleMovement();
391 check(Movement !=
nullptr);
392 check(Movement->Wheels.Num() == WheelsFrictionScale.Num());
394 for (int32 i = 0; i < Movement->Wheels.Num(); ++i)
396 Movement->Wheels[i]->TireConfig->SetFrictionScale(WheelsFrictionScale[i]);
406 UWheeledVehicleMovementComponent4W *Vehicle4W = Cast<UWheeledVehicleMovementComponent4W>(
407 GetVehicleMovement());
408 check(Vehicle4W !=
nullptr);
416 Vehicle4W->EngineSetup.DampingRateZeroThrottleClutchEngaged;
418 Vehicle4W->EngineSetup.DampingRateZeroThrottleClutchDisengaged;
426 TArray<FGearPhysicsControl> ForwardGears;
428 for (
const auto &Gear : Vehicle4W->TransmissionSetup.ForwardGears)
432 GearPhysicsControl.
Ratio = Gear.Ratio;
433 GearPhysicsControl.
UpRatio = Gear.UpRatio;
434 GearPhysicsControl.
DownRatio = Gear.DownRatio;
436 ForwardGears.Add(GearPhysicsControl);
447 UPrimitiveComponent *UpdatedPrimitive = Cast<UPrimitiveComponent>(Vehicle4W->UpdatedComponent);
448 check(UpdatedPrimitive !=
nullptr);
456 TArray<FWheelPhysicsControl> Wheels;
458 for (int32 i = 0; i < Vehicle4W->WheelSetups.Num(); ++i)
463 PxVehicleWheelData PWheelData = Vehicle4W->PVehicle->mWheelsSimData.getWheelData(i);
465 PhysicsWheel.
DampingRate = Cm2ToM2(PWheelData.mDampingRate);
466 PhysicsWheel.
MaxSteerAngle = FMath::RadiansToDegrees(PWheelData.mMaxSteer);
467 PhysicsWheel.
Radius = PWheelData.mRadius;
468 PhysicsWheel.
MaxBrakeTorque = Cm2ToM2(PWheelData.mMaxBrakeTorque);
471 PxVehicleTireData PTireData = Vehicle4W->PVehicle->mWheelsSimData.getTireData(i);
475 PhysicsWheel.
LongStiffValue = PTireData.mLongitudinalStiffnessPerUnitGravity;
482 PhysicsWheel.
TireFriction = Vehicle4W->Wheels[i]->TireConfig->GetFrictionScale();
483 PhysicsWheel.
Position = Vehicle4W->Wheels[i]->Location;
485 Wheels.Add(PhysicsWheel);
491 UWheeledVehicleMovementComponentNW *VehicleNW = Cast<UWheeledVehicleMovementComponentNW>(
492 GetVehicleMovement());
494 check(VehicleNW !=
nullptr);
502 VehicleNW->EngineSetup.DampingRateZeroThrottleClutchEngaged;
504 VehicleNW->EngineSetup.DampingRateZeroThrottleClutchDisengaged;
512 TArray<FGearPhysicsControl> ForwardGears;
514 for (
const auto &Gear : VehicleNW->TransmissionSetup.ForwardGears)
518 GearPhysicsControl.
Ratio = Gear.Ratio;
519 GearPhysicsControl.
UpRatio = Gear.UpRatio;
520 GearPhysicsControl.
DownRatio = Gear.DownRatio;
522 ForwardGears.Add(GearPhysicsControl);
533 UPrimitiveComponent *UpdatedPrimitive = Cast<UPrimitiveComponent>(VehicleNW->UpdatedComponent);
534 check(UpdatedPrimitive !=
nullptr);
542 TArray<FWheelPhysicsControl> Wheels;
544 for (int32 i = 0; i < VehicleNW->WheelSetups.Num(); ++i)
549 PxVehicleWheelData PWheelData = VehicleNW->PVehicle->mWheelsSimData.getWheelData(i);
550 PhysicsWheel.
DampingRate = Cm2ToM2(PWheelData.mDampingRate);
551 PhysicsWheel.
MaxSteerAngle = FMath::RadiansToDegrees(PWheelData.mMaxSteer);
552 PhysicsWheel.
Radius = PWheelData.mRadius;
553 PhysicsWheel.
MaxBrakeTorque = Cm2ToM2(PWheelData.mMaxBrakeTorque);
556 PxVehicleTireData PTireData = VehicleNW->PVehicle->mWheelsSimData.getTireData(i);
559 PhysicsWheel.
LongStiffValue = PTireData.mLongitudinalStiffnessPerUnitGravity;
566 PhysicsWheel.
TireFriction = VehicleNW->Wheels[i]->TireConfig->GetFrictionScale();
567 PhysicsWheel.
Position = VehicleNW->Wheels[i]->Location;
569 Wheels.Add(PhysicsWheel);
592 UWheeledVehicleMovementComponent4W *Vehicle4W = Cast<UWheeledVehicleMovementComponent4W>(
593 GetVehicleMovement());
594 check(Vehicle4W !=
nullptr);
605 Vehicle4W->EngineSetup.DampingRateZeroThrottleClutchEngaged =
607 Vehicle4W->EngineSetup.DampingRateZeroThrottleClutchDisengaged =
616 TArray<FVehicleGearData> ForwardGears;
620 FVehicleGearData GearData;
622 GearData.Ratio = Gear.Ratio;
623 GearData.UpRatio = Gear.UpRatio;
624 GearData.DownRatio = Gear.DownRatio;
626 ForwardGears.Add(GearData);
629 Vehicle4W->TransmissionSetup.ForwardGears = ForwardGears;
636 UPrimitiveComponent *UpdatedPrimitive = Cast<UPrimitiveComponent>(Vehicle4W->UpdatedComponent);
637 check(UpdatedPrimitive !=
nullptr);
646 if (PhysicsWheelsNum != 4)
648 UE_LOG(LogCarla, Error, TEXT(
"Number of WheelPhysicsControl is not 4."));
655 TArray<FWheelSetup> NewWheelSetups = Vehicle4W->WheelSetups;
657 for (int32 i = 0; i < PhysicsWheelsNum; ++i)
659 UVehicleWheel *Wheel = NewWheelSetups[i].WheelClass.GetDefaultObject();
660 check(Wheel !=
nullptr);
663 Wheel->TireConfig = DuplicateObject<UTireConfig>(Wheel->TireConfig,
nullptr);
669 Vehicle4W->WheelSetups = NewWheelSetups;
672 GetWorld()->GetPhysicsScene()->GetPxScene()->lockWrite();
673 Vehicle4W->RecreatePhysicsState();
674 GetWorld()->GetPhysicsScene()->GetPxScene()->unlockWrite();
676 for (int32 i = 0; i < PhysicsWheelsNum; ++i)
678 PxVehicleWheelData PWheelData = Vehicle4W->PVehicle->mWheelsSimData.getWheelData(i);
685 Vehicle4W->PVehicle->mWheelsSimData.setWheelData(i, PWheelData);
687 PxVehicleTireData PTireData = Vehicle4W->PVehicle->mWheelsSimData.getTireData(i);
691 Vehicle4W->PVehicle->mWheelsSimData.setTireData(i, PTireData);
696 UWheeledVehicleMovementComponentNW *VehicleNW = Cast<UWheeledVehicleMovementComponentNW>(
697 GetVehicleMovement());
699 check(VehicleNW !=
nullptr);
708 VehicleNW->EngineSetup.DampingRateZeroThrottleClutchEngaged =
710 VehicleNW->EngineSetup.DampingRateZeroThrottleClutchDisengaged =
719 TArray<FVehicleNWGearData> ForwardGears;
725 GearData.
Ratio = Gear.Ratio;
726 GearData.
UpRatio = Gear.UpRatio;
729 ForwardGears.Add(GearData);
732 VehicleNW->TransmissionSetup.ForwardGears = ForwardGears;
739 UPrimitiveComponent *UpdatedPrimitive = Cast<UPrimitiveComponent>(VehicleNW->UpdatedComponent);
740 check(UpdatedPrimitive !=
nullptr);
753 TArray<FWheelSetup> NewWheelSetups = VehicleNW->WheelSetups;
755 for (int32 i = 0; i < PhysicsWheelsNum; ++i)
757 UVehicleWheel *Wheel = NewWheelSetups[i].WheelClass.GetDefaultObject();
758 check(Wheel !=
nullptr);
761 Wheel->TireConfig = DuplicateObject<UTireConfig>(Wheel->TireConfig,
nullptr);
767 VehicleNW->WheelSetups = NewWheelSetups;
770 GetWorld()->GetPhysicsScene()->GetPxScene()->lockWrite();
771 VehicleNW->RecreatePhysicsState();
772 GetWorld()->GetPhysicsScene()->GetPxScene()->unlockWrite();
774 for (int32 i = 0; i < PhysicsWheelsNum; ++i)
776 PxVehicleWheelData PWheelData = VehicleNW->PVehicle->mWheelsSimData.getWheelData(i);
783 VehicleNW->PVehicle->mWheelsSimData.setWheelData(i, PWheelData);
785 PxVehicleTireData PTireData = VehicleNW->PVehicle->mWheelsSimData.getTireData(i);
789 VehicleNW->PVehicle->mWheelsSimData.setTireData(i, PTireData);
797 if (Recorder && Recorder->IsEnabled())
799 Recorder->AddPhysicsControl(*
this);
821 auto *MovementComponent = GetVehicleMovement();
828 TelemetryData.
EngineRPM = MovementComponent->GetEngineRotationSpeed();
830 TelemetryData.
Drag = MovementComponent->DebugDragMagnitude / 100.0f;
833 FPhysXVehicleManager* MyVehicleManager = FPhysXVehicleManager::GetVehicleManagerFromScene(GetWorld()->GetPhysicsScene());
835 SCOPED_SCENE_READ_LOCK(MyVehicleManager->GetScene());
836 PxWheelQueryResult* WheelsStates = MyVehicleManager->GetWheelsStates_AssumesLocked(MovementComponent);
839 TArray<FWheelTelemetryData> Wheels;
840 for (uint32 w = 0; w < MovementComponent->PVehicle->mWheelsSimData.getNbWheels(); ++w)
844 WheelTelemetryData.
TireFriction = WheelsStates[w].tireFriction;
845 WheelTelemetryData.
LatSlip = FMath::RadiansToDegrees(WheelsStates[w].lateralSlip);
846 WheelTelemetryData.
LongSlip = WheelsStates[w].longitudinalSlip;
847 WheelTelemetryData.
Omega = MovementComponent->PVehicle->mWheelsDynData.getWheelRotationSpeed(w);
849 UVehicleWheel* Wheel = MovementComponent->Wheels[w];
850 WheelTelemetryData.
TireLoad = Wheel->DebugTireLoad / 100.0f;
852 WheelTelemetryData.
Torque = Wheel->DebugWheelTorque / (100.0f * 100.0f);
853 WheelTelemetryData.
LongForce = Wheel->DebugLongForce / 100.f;
854 WheelTelemetryData.
LatForce = Wheel->DebugLatForce / 100.f;
858 Wheels.Add(WheelTelemetryData);
861 TelemetryData.
Wheels = Wheels;
863 return TelemetryData;
869 if (GetWorld()->GetFirstPlayerController())
871 ACarlaHUD* hud = Cast<ACarlaHUD>(GetWorld()->GetFirstPlayerController()->GetHUD());
879 if (hud->
DebugVehicle == GetVehicleMovementComponent()) {
881 GetVehicleMovementComponent()->StopTelemetry();
887 UE_LOG(LogCarla, Warning, TEXT(
"ACarlaWheeledVehicle::ShowDebugTelemetry:: Cannot find HUD for debug info"));
929 check((uint8)WheelLocation >= 0)
930 UVehicleAnimInstance *VehicleAnim = Cast<UVehicleAnimInstance>(GetMesh()->GetAnimInstance());
931 check(VehicleAnim !=
nullptr)
932 VehicleAnim->SetWheelRotYaw((uint8)WheelLocation, AngleInDeg);
936 UE_LOG(LogTemp, Warning, TEXT(
"Cannot set wheel steer direction. Physics are enabled."))
942 check((uint8)WheelLocation >= 0)
943 UVehicleAnimInstance *VehicleAnim = Cast<UVehicleAnimInstance>(GetMesh()->GetAnimInstance());
944 check(VehicleAnim !=
nullptr)
945 check(VehicleAnim->GetWheeledVehicleMovementComponent() !=
nullptr)
949 return VehicleAnim->GetWheeledVehicleMovementComponent()->Wheels[(uint8)WheelLocation]->GetSteerAngle();
953 return VehicleAnim->GetWheelRotAngle((uint8)WheelLocation);
958 if(!GetCarlaMovementComponent<UDefaultMovementComponent>())
963 UWheeledVehicleMovementComponent* Movement = GetVehicleMovement();
966 check(Movement !=
nullptr);
971 SetActorEnableCollision(
true);
972 auto RootComponent = Cast<UPrimitiveComponent>(GetRootComponent());
973 RootComponent->SetSimulatePhysics(enabled);
974 RootComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
976 UVehicleAnimInstance *VehicleAnim = Cast<UVehicleAnimInstance>(GetMesh()->GetAnimInstance());
977 check(VehicleAnim !=
nullptr)
979 GetWorld()->GetPhysicsScene()->GetPxScene()->lockWrite();
982 Movement->RecreatePhysicsState();
983 VehicleAnim->ResetWheelCustomRotations();
987 Movement->DestroyPhysicsState();
990 GetWorld()->GetPhysicsScene()->GetPxScene()->unlockWrite();
1019 Super::EndPlay(EndPlayReason);
1025 UE_LOG(LogTemp, Warning, TEXT(
"This door is not configured for this car."));
1042 UE_LOG(LogTemp, Warning, TEXT(
"This door is not configured for this car."));
1061 DoorComponent->DetachFromComponent(
1062 FDetachmentTransformRules(EDetachmentRule::KeepWorld,
false));
1063 FTransform DoorInitialTransform =
1065 DoorComponent->SetWorldTransform(DoorInitialTransform);
1066 DoorComponent->SetSimulatePhysics(
true);
1067 DoorComponent->SetCollisionProfileName(TEXT(
"BlockAll"));
1068 float AngleLimit = Constraint->ConstraintInstance.GetAngularSwing1Limit();
1069 FRotator AngularRotationOffset = Constraint->ConstraintInstance.AngularRotationOffset;
1071 if (Constraint->ConstraintInstance.AngularRotationOffset.Yaw < 0.0f)
1073 AngleLimit = -AngleLimit;
1075 Constraint->SetAngularOrientationTarget(FRotator(0, AngleLimit, 0));
1078 Constraint->InitComponentConstraint();
1080 UPhysicsConstraintComponent** CollisionDisable =
1082 if (CollisionDisable)
1084 (*CollisionDisable)->InitComponentConstraint();
1094 FTransform DoorInitialTransform =
1096 DoorComponent->SetSimulatePhysics(
false);
1097 DoorComponent->SetCollisionProfileName(TEXT(
"NoCollision"));
1098 DoorComponent->SetWorldTransform(DoorInitialTransform);
1099 DoorComponent->AttachToComponent(
1100 GetMesh(), FAttachmentTransformRules(EAttachmentRule::KeepWorld,
true));
1107 if (Recorder && Recorder->IsEnabled())
1109 Recorder->AddVehicleDoor(*
this, DoorIdx, bIsOpen);
1120 case 0:
CheckRollover(roll, std::make_pair(130.0, 230.0));
break;
1121 case 1:
CheckRollover(roll, std::make_pair(140.0, 220.0));
break;
1122 case 2:
CheckRollover(roll, std::make_pair(150.0, 210.0));
break;
1123 case 3:
CheckRollover(roll, std::make_pair(160.0, 200.0));
break;
1141 if (threshold_roll.first < roll && roll < threshold_roll.second){
1142 auto RootComponent = Cast<UPrimitiveComponent>(GetRootComponent());
1143 auto angular_velocity = RootComponent->GetPhysicsAngularVelocityInDegrees();
1163 TArray<AActor*> ActorsInLevel;
1164 UGameplayStatics::GetAllActorsOfClass(
World, AActor::StaticClass(), ActorsInLevel);
1178 TArray<AActor*> ActorsInLevel;
1179 UGameplayStatics::GetAllActorsOfClass(
World, AActor::StaticClass(), ActorsInLevel);
1191 UPhysicsConstraintComponent* Component)
1193 return Component->ConstraintInstance.AngularRotationOffset;
1197 UPhysicsConstraintComponent* Component,
const FRotator &NewAngle)
1199 Component->ConstraintInstance.AngularRotationOffset = NewAngle;
FVehicleLightState LightState
FVehiclePhysicsControl PhysicsControl
UE_LOG(LogCarla, Log, TEXT("UActorDispatcher::Destroying actor: '%s' %x"), *Id, Actor)
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld * World
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld Actor
EVehicleDoor
Type of door to open/close
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
UWheeledVehicleMovementComponent * DebugVehicle
void AddDebugVehicleForTelemetry(UWheeledVehicleMovementComponent *Veh)
FVector GetVehicleBoundingBoxExtent() const
Extent of the vehicle's bounding box.
void SetWheelsFrictionScale(TArray< float > &WheelsFrictionScale)
FBoxSphereBounds GetBoxSphereBounds() const
void RecordDoorChange(const EVehicleDoor DoorIdx, const bool bIsOpen)
FVehicleLightState LightState
void RestoreVehiclePhysicsControl()
void CloseDoorPhys(const EVehicleDoor DoorIdx)
bool IsTwoWheeledVehicle()
void AddReferenceToManager()
UBoxComponent * VehicleBounds
FVehicleLightState GetVehicleLightState() const
void SetThrottleInput(float Value)
int RolloverBehaviorTracker
carla::rpc::VehicleFailureState GetFailureState() const
void RefreshLightState(const FVehicleLightState &VehicleLightState)
void SetWheelCollisionNW(UWheeledVehicleMovementComponentNW *VehicleNW, const FVehiclePhysicsControl &PhysicsControl)
void SetReverse(bool Value)
TMap< UPrimitiveComponent *, UPhysicsConstraintComponent * > CollisionDisableConstraints
float RolloverBehaviorForce
void SetWheelCollision(UWheeledVehicleMovementComponent4W *Vehicle4W, const FVehiclePhysicsControl &PhysicsControl)
const TArray< int32 > GetFoliageInstancesCloseToVehicle(const UInstancedStaticMeshComponent *Component) const
float GetWheelSteerAngle(EVehicleWheelLocation WheelLocation)
bool IsInVehicleRange(const FVector &Location) const
void SetCarlaMovementComponent(UBaseCarlaMovementComponent *MoementComponent)
FVector GetVehicleOrientation() const
Orientation vector of the vehicle, pointing forward.
virtual void BeginPlay() override
float GetMaximumSteerAngle() const
Get the maximum angle at which the front wheel can steer.
void ApplyVehiclePhysicsControl(const FVehiclePhysicsControl &PhysicsControl)
FVehiclePhysicsControl GetVehiclePhysicsControl() const
TArray< float > GetWheelsFrictionScale()
FVehicleControl LastAppliedControl
void SetFailureState(const carla::rpc::VehicleFailureState &FailureState)
FVehicleTelemetryData GetVehicleTelemetryData() const
static void SetPhysicsConstraintAngle(UPhysicsConstraintComponent *Component, const FRotator &NewAngle)
void SetVehicleLightState(const FVehicleLightState &LightState)
void CheckRollover(const float roll, const std::pair< float, float > threshold_roll)
TArray< UPhysicsConstraintComponent * > ConstraintsComponents
int32 GetVehicleCurrentGear() const
Active gear of the vehicle.
struct ACarlaWheeledVehicle::@1 InputControl
FVehiclePhysicsControl LastPhysicsControl
static FRotator GetPhysicsConstraintAngle(UPhysicsConstraintComponent *Component)
float GetVehicleForwardSpeed() const
Forward speed in cm/s. Might be negative if goes backwards.
void SetBrakeInput(float Value)
void CloseDoor(const EVehicleDoor DoorIdx)
TMap< UPhysicsConstraintComponent *, UPrimitiveComponent * > ConstraintDoor
void SetSimulatePhysics(bool enabled)
FTimerHandle TimerHandler
void DeactivateVelocityControl()
TMap< UPrimitiveComponent *, FTransform > DoorComponentsTransform
virtual FVector GetVelocity() const override
FBox GetDetectionBox() const
void SetSteeringInput(float Value)
void ShowDebugTelemetry(bool Enabled)
void ApplyRolloverBehavior()
Rollovers tend to have too much angular velocity, resulting in the vehicle doing a full 360º flip.
UBaseCarlaMovementComponent * BaseMovementComponent
FTransform GetVehicleTransform() const
Transform of the vehicle.
TArray< FName > ConstraintComponentNames
void ActivateVelocityControl(const FVector &Velocity)
void DrawFoliageBoundingBox() const
void UpdateDetectionBox()
void FlushVehicleControl()
void ApplyVehicleControl(const FVehicleControl &Control, EVehicleInputPriority Priority)
ACarlaWheeledVehicle(const FObjectInitializer &ObjectInitializer)
void OpenDoor(const EVehicleDoor DoorIdx)
carla::rpc::VehicleFailureState FailureState
void OpenDoorPhys(const EVehicleDoor DoorIdx)
float GetDetectionSize() const
void AdjustVehicleBounds()
void SetWheelSteerDirection(EVehicleWheelLocation WheelLocation, float AngleInDeg)
Set the rotation of the car wheels indicated by the user 0 = FL_VehicleWheel, 1 = FR_VehicleWheel,...
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason)
bool bAckermannControlActive
UVehicleVelocityControl * VelocityControl
FTransform GetVehicleBoundingBoxTransform() const
Transform of the vehicle's bounding box relative to the vehicle.
void SetHandbrakeInput(bool Value)
void RemoveReferenceToManager()
FAckermannController AckermannController
FTransform LocalToGlobalTransform(const FTransform &InTransform) const
void AddVehicle(ACarlaWheeledVehicle *Vehicle)
void RemoveVehicle(ACarlaWheeledVehicle *Vehicle)
void UpdateVehicleState(const ACarlaWheeledVehicle *Vehicle)
void RunLoop(FVehicleControl &Control)
void UpdateVehiclePhysics(const ACarlaWheeledVehicle *Vehicle)
virtual void ProcessControl(FVehicleControl &Control)
virtual int32 GetVehicleCurrentGear() const
virtual float GetVehicleForwardSpeed() const
virtual FVector GetVelocity() const
static FBoundingBox GetVehicleBoundingBox(const ACarlaWheeledVehicle *Vehicle, uint8 InTagQueried=0xFF)
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
static ACarlaRecorder * GetRecorder(const UObject *WorldContextObject)
static void CreateDefaultMovementComponent(ACarlaWheeledVehicle *Vehicle)
float Ratio
Determines the amount of torque multiplication
float DownRatio
Value of engineRevs/maxEngineRevs that is low enough to gear down
float UpRatio
Value of engineRevs/maxEngineRevs that is high enough to gear up
bool UseSweepWheelCollision
TArray< FWheelPhysicsControl > Wheels
float DampingRateFullThrottle
float DampingRateZeroThrottleClutchEngaged
float DampingRateZeroThrottleClutchDisengaged
TArray< FGearPhysicsControl > ForwardGears
TArray< FWheelTelemetryData > Wheels
float NormalizedLongForce