I get an "error LNK2019" when using ATriggerVolume in my code

This snippet below throws an LNK2019 unresolved external symbol error when I build:

UGameplayStatics::GetAllActorsOfClass(this, ATriggerVolume::StaticClass(), outActors);		

But the same code works perfectly if I use the parent class AVolume instead of ATriggerVolume:

UGameplayStatics::GetAllActorsOfClass(this, AVolume::StaticClass(), outActors);				

Any ideas what could be causing this? I’ve tried all kinds of fixes for an hour now but I feel like I’m missing something very basic here :frowning:

I understand that AVolumeTrigger is a part of the module “Engine” which is already included in my build.cs file as shown below.

PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", });        

Full error is as follows:
error LNK2019: unresolved external symbol “private: static class UClass * __cdecl ATriggerVolume::GetPrivateStaticClass(wchar_t const *)” (?GetPrivateStaticClass@ATriggerVolume@@CAPEAVUClass@@PEB_W@Z) referenced in function “class ATriggerVolume * __cdecl Cast<class ATriggerVolume>(class UObject *)” (??$Cast@VATriggerVolume@@@@YAPEAVATriggerVolume@@PEAVUObject@@@Z)

TriggerVolume is not marked as an exported class. You could add MinimalAPI to the UCLASS macro of ATriggerVolume if you are compiling your own engine code.

You could also do UClass* TriggerVolumeClass = FindObject<UClass>(ANY_PACKAGE, TEXT(“TriggerVolume”)); to get the class. Not ideal, but will get you the UClass* you want.

Thanks, that works. I’d erroneously assumed that classes for widely used components would be available OOTB. Even with the UClass workaround I can’t cast the outActors" back to a TriggerVolume unless that class is exported, right?

Anyway for my purposes I should be able to get away with casting the results to AVolume.

Does that mean that we cannot create a subclass from ATriggerVolume? I’m trying to do this and it won’t link. Any work-arounds without recompiling the engine? I am able to create a subclass from the ATriggerBox class instead and it looks the same. Is there any major differences between ATriggerVolume and ATriggerBox?

It sure sounds like it. I had a similar requirement and I ended up creating an Actor class with an appropriate shape component (BoxComponent / SphereComponent/ etc) to serve as a trigger volume. Not sure if someone else is aware of a workaround to subclass unexported classes without tagging them for export and recompiling the engine. Would love to know of one.

I’m guessing there’s a good reason for it, be interesting to know what it is. Mind you, Trigger Volumes shouldn’t be all that difficult to reproduce are they?