Description

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.

Steps to Reproduce
  1. Create a new project using the code Vehicle Advanced template.
  2. Build the project in Visual Studio.
  3. Open the project in the Editor.
  4. Add a new code class derived from WheeledVehicleMovementComponent. Name the class MyWheeledVehMoveComp.
  5. Close the Editor.
  6. Reload the solution in Visual Studio.
  7. In the header file for the new class, change GENERATED_BODY() to GENERATED_UCLASS_BODY() and add the following code:
    #if WITH_VEHICLE
    	virtual void SetupVehicle() override;
    #endif
    
  8. In the .cpp file for the new class, add the following code:
    #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;
    		}
    	}
    }
    
  9. Build the project in Visual Studio.

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.

Have Comments or More Details?

Head over to the existing Questions & Answers thread and let us know what's up.

0
Login to Vote

Fixed
ComponentUE - Simulation - Physics
Affects Versions4.5.14.7
Fix Commit2366444
CreatedNov 19, 2014
ResolvedNov 20, 2014
UpdatedApr 27, 2018
View Jira Issue