ATriggerVolume not registering

When I add #include “Engine/TriggerVolume.h” as the last #include in my header file it works, but when I try and create ATriggerVolume* the ATriggerVolume* doesn’t register and other things in the header file like the GENERATED_BODY() stops working.

Hi @ThatsShocking ,

Couple things here.

1.) The generated.h file should always be the final include this is probably the source of your issues with the generated body.

2.) Try moving your include of trigger volume to the .cpp file and then forward declaring the trigger volume class like this.

UPROPERTY()
class ATriggerVolume* PressurePlate;

As a side note, I’ve found that not adding UPROPERTY() to normal pointers prevents some nasty behavior with respect to garbage collection iirc.

I did step one and the squiggles went away, but I get a whole bunch of new errors when I try and compile now.
I’m not quite sure how to do step 2.Where exactly do I type “UPROPERTY() class ATriggerVolume* PressurePlate;” in the .cpp file?

Hey there. I’ve been camping, sorry for the delayed reply. You want to keep the class variable as is. You only want to move the include of trigger volume to the .cpp (implementation) file. I’m on my phone so hopefully this code snippet will format correctly.

Header file (.h)

UPROPERTY()
class ATriggerVolume* MyVolume;

Implementation file (.cpp)

#include "Engine/TriggerVolume.h"
1 Like

Had the same problem. This solved it. Thanks.

Thanks for this. I was having all these same problems and one thing to point out is that adding the word class in front of ATriggerVolume seems to help. He didn’t do that in his video but it worked. They must have changed some things. I’m using UE5.

Actually it worked yesterday but today it’s failing. More exploration needed.