Download

C++ won't compile after creating class with TriggerBox as parent.

I’m not sure if this is something I shouldn’t be doing.

But when I create a new class with TriggerBox as the parent in the Editor, when I switch back to my C++ won’t compile and will give errors in the TriggerBase.h files and such.

Is this a bug or am I doing something wrong?

Thanks all :slight_smile:

I’ve probably mucked around with this for longer than I should - only because I kept modify engine code by accident and causing a full recompile three times!

Yup, I get the compile error. ->

You can get around it initially by inlcuding #include “Engine/TriggerBox.h and TriggerBase.h” but then it complains about being unable to find the implementation of TriggerBox::EditorApplyScale.

This function is implemented in TriggerActors.cpp and I can’t see how it’s exposed.

Now, TriggerBase.h has this comment:

Which leads me to believe this is strictly for use in Blueprints.

Could you use a UBoxComponent instead and implement functions for OnComponentBeginOverlap and OnComponentEndOverlap ?


UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = VASA)
TSubobjectPtr<UBoxComponent> DoorCollision;
DoorCollision->OnComponentBeginOverlap.AddDynamic(this, &AVSDoor::OnBeginOverlapDoorCollision);
DoorCollision->OnComponentEndOverlap.AddDynamic(this, &AVSDoor::OnEndOverlapDoorCollision);	

Thanks for the reply!

I was able to inherit from trigger in UE3 with unrealscript which is why I was perplexed.

Glad it wasn’t just me. Yeah I’ve taken your advice and am using the box component instead :slight_smile: Thanks for the code at the bottom too! I was going to link the overlap functions in Blueprints but your way seems a lot better!

Cool :slight_smile:
I’m guessing creating classes via the editor should at least warn you.

You could also use a UShapeCompnent so you’re not restricted to a box - just like TriggerBase does :slight_smile:
https://github.com/EpicGames/UnrealEngine/blob/69b5693c869697b828e1f2c24004ff1481b5fb98/Engine/Source/Runtime/Engine/Classes/Engine/TriggerBase.h#L20

I’m not sure I’m doing things The Right Way but I’m more comfortable in C++ than in Blueprints. So I adorn those callbacks with BlueprintNativeEvent and provide the default implementation in C++ but allow them to be overridden by modders.

There is also an ATriggerVolume that you can extend from. It seems to be the same thing as TriggerBox.