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