I work with C++ sometimes and I have no problems with it. But Unreal is a real p* in the a* sometimes. VS doesn’t help either.
I need some guidance from the community here to find my way out of this mess that is Unreal
This is an example of my daily struggle. I have this code.
Anything compiles here. My class is a very basic Actor class and this is in the constructor.
static ConstructorHelpers::FObjectFinder<UStaticMesh> particleMeshAux(TEXT("StaticMesh'/Engine/BasicShapes/Sphere.Sphere'"));
if (particleMeshAux.Object != nullptr)
particleMesh = particleMeshAux.Object;
else
UE_LOG(ObiLog, Error, TEXT("Failed loading Sphere Static Mesh."));
**QUESTION 1) **Should I include StaticMesh.h?. Or should I include a higher .h that contains all the basic stuff? That’s something I always doubt about.
So I look in the docs and find the class page. Then I see the last line about the file to include:
[TABLE=“cellspacing: 0”]
Module
Engine
Header
Runtime/Engine/Classes/Engine/StaticMesh.h
I guess I don’t have to include Engine module… in the module list of the project. Right?
QUESTION 2) What do I have to include? some engine superior .h file? I’ve seen sometimes a engine.h include or something like that.
**QUESTION 3) **Why some people include just “StaticMesh.h”, sometimes “Engine/StaticMesh.h” or where should I start?
Then I put: #include “Engine/StaticMesh.h” . I have no idea if that’s the right way.
Then I see ConstructionHelpers is not detected. I find the official page:
[TABLE=“cellspacing: 0”]
Module
CoreUObject
Header
Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h
Should I include CoreUObject somewhere in the project list of modules? I guess not… because it’s a Core … module?..
QUESTION 4) Again, should I include this header or not? or it comes with some superior .h file that I should Include?
QUESTION 5) how do I include this?. As before, “UObject/ConstructorHelpers.h” ?? “Runtime/ConstructorHelpers.h”?? “CoreUObject/ConstructorHelpers.h” or just “ConstructorHelpers.h”??
I just have no idea how this works. I read the documents about the build system, and everything that I got, and still don’t get this mess. Sometimes I include something directly and it works, sometimes I have no idea which of the path items I should include.
After this, I will definitely write a wiki page or article about this, I’ve been working with Unreal this past year and it’s been a really crazy experience (coming from Unity, Qt, and other C++ frameworks).
Thanks a lot.