When a code class deriving from WheeledVehicleMovementComponent is created in a Vehicle Advanced template project, the user is required to include a constructor for the FWheelSetup struct in WheeledVehicleMovementComponent because the constructor is included in the .cpp file for that class instead of in the .h file.
#if WITH_VEHICLE
virtual void SetupVehicle() override;
#endif
#include "Vehicles/VehicleWheel.h" // ... UMyWheeledVehMoveComp::UMyWheeledVehMoveComp(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { WheelSetups.SetNum(4); } void UMyWheeledVehMoveComp::SetupVehicle() { for (int32 WheelIdx = 0; WheelIdx < WheelSetups.Num(); ++WheelIdx) { const FWheelSetup& WheelSetup = WheelSetups[WheelIdx]; if (WheelSetup.BoneName == NAME_None) { return; } } }
RESULT:
The build fails with an unresolved external error.
EXPECTED:
The build completes successfully.
WORKAROUND:
Adding the following code to the .cpp file of the new class allows the project to build successfully:
#if WITH_EDITOR && !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
FWheelSetup::FWheelSetup() : WheelClass(UVehicleWheel::StaticClass()), BoneName(NAME_None), AdditionalOffset(0.0f)
{
}
#endif
This is a copy of the constructor for the FWheelSetup struct in WheeledVehicleMovementComponent.
Head over to the existing Questions & Answers thread and let us know what's up.
0 |
Component | UE - Simulation - Physics |
---|---|
Affects Versions | 4.5.1, 4.7 |
Fix Commit | 2366444 |
---|
Created | Nov 19, 2014 |
---|---|
Resolved | Nov 20, 2014 |
Updated | Apr 27, 2018 |