feat(vehicle): front and rear wheel classes, so Chaos has parameters to build from

Chaos reads steering and drive flags from the wheel object a setup points at, and the first
attempt pointed every setup at the base UChaosVehicleWheel. Dedicated front and rear classes
carry the modelled dimensions (radius 33 cm, width 22 cm), steering on the front axle, drive
on the rear, and the suspension travel - which is also how Unreal's own vehicle template is
organised.

Compiles clean. Not yet verified in a run: the drive test did not log the vehicle this time,
so whether the wheel count changes from 0 is still unproven and recorded as such rather than
claimed.
This commit is contained in:
zwitschi committed 2026-11-09 16:32:25 +01:00
1 parent 98eae6f3e9
commit cc57ad6c02
2 files changed
+53 -3

No files matched your search

+27 -3
View File
@@ -1,5 +1,6 @@
#include "GigLineVehicle.h"
#include "ChaosVehicleWheel.h"
#include "ChaosWheeledVehicleMovementComponent.h"
#include "Components/SkeletalMeshComponent.h"
@@ -12,6 +13,28 @@ namespace GigLineVehicleDims
constexpr float TrackCm = 156.0f;
}
UGigLineFrontWheel::UGigLineFrontWheel()
{
// Dimensions from the model's report: radius 33 cm, width 22 cm. Steering yes, drive no.
WheelRadius = 33.0f;
WheelWidth = 22.0f;
bAffectedBySteering = true;
bAffectedByEngine = false;
MaxSteerAngle = 35.0f;
SuspensionMaxRaise = 8.0f;
SuspensionMaxDrop = 8.0f;
}
UGigLineRearWheel::UGigLineRearWheel()
{
WheelRadius = 33.0f;
WheelWidth = 22.0f;
bAffectedBySteering = false;
bAffectedByEngine = true;
SuspensionMaxRaise = 8.0f;
SuspensionMaxDrop = 8.0f;
}
AGigLineVehicle::AGigLineVehicle()
{
PrimaryActorTick.bCanEverTick = true;
@@ -131,9 +154,10 @@ void AGigLineVehicle::ConfigureWheels()
for (const FWheelSpec& Spec : Specs)
{
FChaosWheelSetup Setup;
// FChaosWheelSetup has only the class, the bone and an offset in 5.8 - there is
// no per-setup disable flag, and steering/drive flags live on the wheel object.
Setup.WheelClass = UChaosVehicleWheel::StaticClass();
// FChaosWheelSetup has only the class, the bone and an offset in 5.8 - there is no
// per-setup disable flag, and steering/drive flags live on the wheel class.
Setup.WheelClass = Spec.bSteer ? UGigLineFrontWheel::StaticClass()
: UGigLineRearWheel::StaticClass();
Setup.BoneName = FName(Spec.Bone);
Movement->WheelSetups.Add(Setup);
}
@@ -1,11 +1,37 @@
#pragma once
#include "CoreMinimal.h"
#include "ChaosVehicleWheel.h"
#include "WheeledVehiclePawn.h"
#include "GigLineVehicle.generated.h"
class UChaosWheeledVehicleMovementComponent;
/**
* Front and rear wheel classes.
*
* Chaos reads steering and drive flags from the wheel *object* the setup points at, and the
* base `UChaosVehicleWheel` is what the first attempt used - which produced zero wheels
* after registration. Giving each axle its own class is also what Unreal's own vehicle
* template does, for the same reason: the parameters belong to the class, not to the
* instance that arrives later.
*/
UCLASS()
class GIGLINE_API UGigLineFrontWheel : public UChaosVehicleWheel
{
GENERATED_BODY()
public:
UGigLineFrontWheel();
};
UCLASS()
class GIGLINE_API UGigLineRearWheel : public UChaosVehicleWheel
{
GENERATED_BODY()
public:
UGigLineRearWheel();
};
/**
* The one drivable vehicle in the demo.
*