Hi!
I’m trying to create a C++ class based on a PhysicsThrusterComponent. It generates the files, but it can’t compile and gives me this error:
EDIT: Here’s the error text from the output log so you can see all of it:
CompilerResultsLog:Error: Error MainThruster.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UPhysicsThrusterComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@UPhysicsThrusterComponent@@UEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z)
CompilerResultsLog:Error: Error MainThruster2.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UPhysicsThrusterComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@UPhysicsThrusterComponent@@UEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z)
CompilerResultsLog:Error: Error ASSC.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UPhysicsThrusterComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@UPhysicsThrusterComponent@@UEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z)
CompilerResultsLog:Error: Error C:\Users\SCiFiR3\Documents\repos\ASSC\Binaries\Win64\UE4Editor-ASSC-1879.dll : fatal error LNK1120: 1 unresolved externals
I tried to create it in an empty project as well, I still get the same thing. Anyone have any idea? Something wrong with my system/project or is it an Unreal Engine bug of some sort?
Thanks.
Hi SCiFiR3,
The reason this is failing is because the UPhysicsThrusterComponent
class is not fully exposed for subclassing. If you built your Engine from source code, you can make an adjustment to the UPhysicsThrusterComponent
class to allow this to compile, but I have not done any testing to make sure the Component would still work properly in a game project. In the PhysicsThrusterComponent.h file, remove the minimalapi
specifier from the UCLASS macro, and add ENGINE_API
to the class. So those two lines should end up looking like this:
UCLASS(hidecategories=(Object, Mobility, LOD), ClassGroup=Physics, showcategories=Trigger, meta=(BlueprintSpawnableComponent))
class ENGINE_API UPhysicsThrusterComponent : public USceneComponent
That will allow you to compile your project with your new custom PhysicsThrustComponent class. As I mentioned though, I don’t know for sure if it will work correctly when you add it to an Actor in your project. This will also require at least a partial rebuild of the Engine since you are changing Engine source code.
Possibly a better option, and the only way you could do this if you are using the binary version of the Engine installed by the launcher, would be to make your own PhysicsThrusterComponent. You can do this by making a custom SceneComponent class, which is fully exposed for subclassing. Then add in the functionality from the UPhysicsThrusterComponent
class (this is a relatively simple class, so that shouldn’t be difficult) and include your own custom functionality that you need.
Got it! Second option sounds like the ticket, thank you !