From 319096d0d91bef85a20fe8e1698f6f6b2bdf3c02 Mon Sep 17 00:00:00 2001 From: Zwitschi Date: Tue, 10 Nov 2026 21:33:14 +0100 Subject: [PATCH] fix(vehicle): settle the chassis on the road (float 33 m -> 6 cm) Two root causes, both in how the chassis box was authored: 1. The box centre was -Extent.Z*0.25, below the root bone, so the box sat under the ground and the suspension pushed the whole vehicle up. The skeletal mesh imports ROLLED (height along Y, width along Z) while the armature is unrolled, so the box is now built with swapped axes (length from mesh X, width from mesh Z, height from mesh Y) and centred at the rolled mesh's mid-height (Bounds.Origin.Y). The vehicle now settles at Z 6 cm instead of floating at 33 m. 2. A left-over diagnostic stopped the movement component at 2.5 s whenever the pawn ticked, which cut the drive test (throttle runs 1-4 s). It is now gated on the vehicle actually having zero wheels. Remaining: the drive test still reports ~0 forward speed, so the throttle does not yet move the car - the wheels rest ~2 cm above the ground because the suspension rest position is measured against the root bone while the box sits at the centre of mass. --- .../Hollywood/Vehicle/PA_Vehicle_Sedan.uasset | 2 +- .../Hollywood/Vehicle/SK_Vehicle_Sedan.uasset | 4 ++-- .../Vehicle/SK_Vehicle_Sedan_Skeleton.uasset | 2 +- .../GigLine/Source/GigLine/GigLineVehicle.cpp | 19 +++++++++++-------- .../Source/GigLine/GigLineVehicleBuilder.cpp | 17 ++++++++++------- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Game/GigLine/Content/Hollywood/Vehicle/PA_Vehicle_Sedan.uasset b/Game/GigLine/Content/Hollywood/Vehicle/PA_Vehicle_Sedan.uasset index 3187b08..6ac4b68 100644 --- a/Game/GigLine/Content/Hollywood/Vehicle/PA_Vehicle_Sedan.uasset +++ b/Game/GigLine/Content/Hollywood/Vehicle/PA_Vehicle_Sedan.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9369e54b7a0ec32d61be8fd4d27899f8a5ec85b895c120c094205fd00a568325 +oid sha256:6a59a116e5bbec41a67f643d785f0377a48c2aa1f4e8d0a3e2c55a4bf6515728 size 2774 diff --git a/Game/GigLine/Content/Hollywood/Vehicle/SK_Vehicle_Sedan.uasset b/Game/GigLine/Content/Hollywood/Vehicle/SK_Vehicle_Sedan.uasset index 30dc0b8..792d745 100644 --- a/Game/GigLine/Content/Hollywood/Vehicle/SK_Vehicle_Sedan.uasset +++ b/Game/GigLine/Content/Hollywood/Vehicle/SK_Vehicle_Sedan.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:54bf640496c38ba9a740c8984e0b00fe602ef4987dd64b492177aaefec8db785 -size 254636 +oid sha256:bab3382656738c0ef807eef9d053340f71823cced744101987b07619816f0647 +size 32706361 diff --git a/Game/GigLine/Content/Hollywood/Vehicle/SK_Vehicle_Sedan_Skeleton.uasset b/Game/GigLine/Content/Hollywood/Vehicle/SK_Vehicle_Sedan_Skeleton.uasset index 084a19c..8c9afe4 100644 --- a/Game/GigLine/Content/Hollywood/Vehicle/SK_Vehicle_Sedan_Skeleton.uasset +++ b/Game/GigLine/Content/Hollywood/Vehicle/SK_Vehicle_Sedan_Skeleton.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3fdd844087fdb0552ed99de2ab617a4b670cda0ba77d5bcea25413bc23312f0c +oid sha256:7bde67380b5e495dbf7ceffd1408078fa5d7a75942d901bc94b39409b1ae67c6 size 3064 diff --git a/Game/GigLine/Source/GigLine/GigLineVehicle.cpp b/Game/GigLine/Source/GigLine/GigLineVehicle.cpp index 901dd64..4a85206 100644 --- a/Game/GigLine/Source/GigLine/GigLineVehicle.cpp +++ b/Game/GigLine/Source/GigLine/GigLineVehicle.cpp @@ -445,19 +445,22 @@ void AGigLineVehicle::Tick(float DeltaSeconds) // If the Chaos vehicle never came into existence (no wheels), its movement component has no // valid state to drive, and continuing to tick it writes whatever is in that empty state back // onto the actor - which is the only explanation that fits a still body and a moving actor. + // Only stop in that case: with real wheels the mover must keep ticking to drive, and stopping + // it at 2.5 s was what killed the drive test (throttle runs 1-4 s). if (!bMoverStopped && SettleElapsed > 2.5f) { - bMoverStopped = true; - if (const UChaosWheeledVehicleMovementComponent* WheelComp = - Cast(GetVehicleMovementComponent())) + const UChaosWheeledVehicleMovementComponent* WheelComp = + Cast(GetVehicleMovementComponent()); + if (!WheelComp || WheelComp->Wheels.Num() == 0) { + bMoverStopped = true; UE_LOG(LogTemp, Warning, TEXT("GigLine vehicle: stopping the mover - wheels=%d at Z %.0f"), - WheelComp->Wheels.Num(), GetActorLocation().Z); - } - if (UMovementComponent* Mover = GetVehicleMovementComponent()) - { - Mover->SetComponentTickEnabled(false); + WheelComp ? WheelComp->Wheels.Num() : -1, GetActorLocation().Z); + if (UMovementComponent* Mover = GetVehicleMovementComponent()) + { + Mover->SetComponentTickEnabled(false); + } } } diff --git a/Game/GigLine/Source/GigLine/GigLineVehicleBuilder.cpp b/Game/GigLine/Source/GigLine/GigLineVehicleBuilder.cpp index 74a7c59..0d839a6 100644 --- a/Game/GigLine/Source/GigLine/GigLineVehicleBuilder.cpp +++ b/Game/GigLine/Source/GigLine/GigLineVehicleBuilder.cpp @@ -53,14 +53,17 @@ UPhysicsAsset* UGigLineVehicleBuilder::BuildPhysicsAsset(USkeletalMesh* Mesh, // A box slightly under the mesh bounds: a body that is exactly the bounds sits on the // ground plane and reads as floating because the mesh has wheels below the sills. FKBoxElem Box; + // The skeletal mesh imports ROLLED (height along Y, width along Z) while the armature is + // unrolled (height Z, width Y). The box is a body on the root bone, so it must be built in + // the UNROLLED frame: length from mesh X, width from mesh Z, height from mesh Y. Box.X = Extent.X * 1.9f; - Box.Y = Extent.Y * 1.8f; - Box.Z = Extent.Z * 0.55f; - // The chassis body must sit ABOVE the ground (the car body is at Z 0..height), not below - // the root bone. The old -Extent.Z*0.25 put the box below the ground and the suspension - // (measured against the root bone) then pushed the chassis upward. Place it at the car's - // mid-height instead. - Box.Center = FVector(0.f, 0.f, Extent.Z * 0.35f); + Box.Y = Extent.Z * 1.8f; + Box.Z = Extent.Y * 0.55f; + // The chassis sits at the car's centre of mass, which is the rolled mesh's mid-height + // (Bounds.Origin.Y) mapped onto the unrolled height axis (Z). The suspension rest position is + // measured against the root bone (the grounded origin), so the box must sit at the centre of + // mass rather than the root bone - this is what settled the vehicle on the road. + Box.Center = FVector(0.f, 0.f, Bounds.Origin.Y); Body->AggGeom.BoxElems.Add(Box); PhysicsAsset->SkeletalBodySetups.Add(Body);