The FWheelSetup constructor is not in the header file. So when one derives from this class (to create a tank movement class, for example), we need to define this constructor in our derived class because it is not defined in the header file WheeledVehicleMovementComponent.h. But the problem is when we define it here it will not allow us to package our game or produce any binaries, only the Editor builds will work.
In WheeledVehicleMovementComponent.h file:
In WheeledVehicleMovementComponent.cpp file:
So basically this definition should be moved into the header file and then we can derive from this class without any issues between Editor builds and Executable/Game/Shipping builds.
In the derived class just copy verbatim the WheeledVehicleMovementComponent4W class but rename it to something else. It should complain about the FWheelSetup class not having a constructor. So we defined one in the derived class. It works when in the editor but not when packaging the build. When packaging the build the linker complains that the constructor is already defined. My only solution right now to get both builds to work is the following:
I spent some more time today trying to reproduce this, and was still unsuccessful in getting the package to fail. I copied the contents of WheeledVehicleMovementComponent4W into my custom class, and after making all of the necessary name changes, I ran into a build error in Visual Studio that said there was a problem with a couple dll’s.
I went back to the default custom class and only added in the portion of code from WheeledVehicleMovementComponent4W that referenced FWheelSetup, and that did not cause any problems. This is what I currently have in my custom class:
Just add this in your constructor:
Then I get this error:
1>MyWheeledVehMovComp.cpp.obj : error LNK2019: unresolved external symbol “public: __cdecl FWheelSetup::FWheelSetup(void)” (??0FWheelSetup@@QEAA@XZ) referenced in function “void __cdecl DefaultConstructItems(void *,int)” (??$DefaultConstructItems@UFWheelSetup@@@@YAXPEAXH@Z)
I should note that our vehicle has more wheels than 4 and we cannot set this unless we include the following code:
Sorry it took so long to reproduce this issue. I was looking for an error when packaging the game in the Editor, when I should have been focusing on looking for a build error in Visual Studio. I was able to reproduce the issue that you described, and have entered a report to have this investigated further (UE-5632).
Yeah, the error occurs when just doing a normal build in visual studio. When I define the constructor then I no longer have the error. But then and only then, we have an error when we package the game. So the only workaround was adding those pre-compiler definitions/checks.
I just wanted to provide a quick update. I just tested this again in our latest internal version of the Engine, and it appears to be working now. The fix should be available in a future release version of the Engine, but most likely not in 4.6.
The fix was added in this commit. Instead of moving the definition into the header file, the struct was declared with ENGINE_API to properly expose it to be overridden. I did not do any extensive testing with it, just checked to make sure I could build the project with the test case I had created to test the issue you were describing. Please let us know if you run into any additional trouble with this fix.