ATriggerVolume problem SOLUTION (without ANY errors!)

You just have organize your includes like this:
#include “CoreMinimal.h”
#include “Components/ActorComponent.h”
#include “Engine/TriggerVolume.h”
#include “OpenDoor.generated.h”

and then have only ONE empty line before UCLASS, or it will produce errors.
So, generally, you must have a code like this at the top of your file, and everything will work fine:

#include “CoreMinimal.h”
#include “Components/ActorComponent.h”
#include “Engine/TriggerVolume.h”
#include “OpenDoor.generated.h”

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )

11 Likes

Works like a Charm, thanks.

Thanks a LOT!!! This Solved my errors

And why is it working like this? As far as I know the sequence of includes shouldn’t matter. And what is with the only one line between the inlcudes and the Macro? Why does it matter?

I works for me too with your solution by the way so thanks :slight_smile:

Hi, i really don’t know, it was suprising for me too. Seems to be all this
UE4 special macro stuff has some hidden detalis. Also, maybe it’s Visual
Studio can’t parse and bind that large amount of code correctly. You’d
better ask Ben Tristem).

I see. Thanks for your answer.

The generated.h include must always go last. I believe it is because the component header file will not know where the classes in TriggerVolume.h are when it loads because they have not loaded yet. Moving it up makes sure that the TriggerVolume classes get loaded first and are ready for the generated.h file to access.

It’s work on me too, thx!

I suggest Ben include this error in the lecture some day, it’s really confusing.

3 Likes

It is a strange one. It seems having the right amount of space between any given macro and other code is important.

Hey everyone!
So for all of you wondering why opendoor.generated.h must be last, heres the answer for better understanding.
Opendoor.generated.h contains code, which is compiled at the end of the build (such as warnings, body, checking if code is in class, class declaration, etc.). The reason why this matters is simple. Imagine you’re baking a cake. Are you gonna mash up the ingredients first and bake the cake later, or are you gonna bake the cake first and then add the ingredients (exclude the toppings from this one :slight_smile: ). It’s basicly the same in programming. The program must follow a series of instructions as one could say, in order for it to work. Hope you get the meaning now and why it matters here. HOWEVER, it would no matter for example when making a program like a picture viewer. Why ? because you would only use includes from library you needed, and there would be no background API (application programming interface) connections, it would be a simple program doing a siple job. Alltho it varies from language to language :slight_smile:
Anyways hope i didnt make stuff too complicated here.

1 Like

It solved my problem. Thanks very much!
I hope the instructors will explain why it will cause problems if we leave space more than one empty line between the UCLASS macro and the last include.
That’s really weird.

Thank you sooooooooooooooo much! I don’t believe that only ONE empty line before UCLASS was needed.

I mean why is this even an issue? It would be sweet If someone can explain it.

Thanks. It’s became a handy one.

Or instead of that you can add this in your opendoor.h:
#include “CoreMinimal.h”
#include “Components/ActorComponent.h”
#include “Runtime/Engine/Classes/Engine/TriggerVolume.h”
#include “OpenDoor.generated.h”

You can add as many lines in the top of your .h files as you need. You just have to perform the project reset procedure, discussed in lecture 84, after you add the lines.

I add a number of empty lines when I first create a class and then perform the project rest. This gives you lines to drop #inlcude directives, and anything else that needs to go above the UCLASS macro.

The issue is this… It has to do with EPIC changing the structure of the URE4 source code structure to use what they call IWYU (include-what-you-use). This is also why you have to include the header files for some functionality in order for the VS intellisense to work correctly. I think this started with version 4.17. The .generated.h files have code that directly reference the UCLASS line number. If that moves it breaks the generated file. When you reset the project the generated files get removed and rebuilt.

Hope this helps.

why my pressure plate is empty??

Privacy & Terms