From cc57ad6c02ed2f0ccbe7b74995299ec3edb06904 Mon Sep 17 00:00:00 2001 From: Zwitschi Date: Mon, 9 Nov 2026 16:32:25 +0100 Subject: [PATCH] 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. --- .../GigLine/Source/GigLine/GigLineVehicle.cpp | 30 +++++++++++++++++-- Game/GigLine/Source/GigLine/GigLineVehicle.h | 26 ++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/Game/GigLine/Source/GigLine/GigLineVehicle.cpp b/Game/GigLine/Source/GigLine/GigLineVehicle.cpp index 1def3b7..ecf9069 100644 --- a/Game/GigLine/Source/GigLine/GigLineVehicle.cpp +++ b/Game/GigLine/Source/GigLine/GigLineVehicle.cpp @@ -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); } diff --git a/Game/GigLine/Source/GigLine/GigLineVehicle.h b/Game/GigLine/Source/GigLine/GigLineVehicle.h index 1673300..c6b9f2e 100644 --- a/Game/GigLine/Source/GigLine/GigLineVehicle.h +++ b/Game/GigLine/Source/GigLine/GigLineVehicle.h @@ -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. *