I am trying to add a UPhysicsHandleComponent variable which requires including "PhysicsEngine/PhysicsHandleComponent.h". When I add the include at the top, it breaks the UCLASS macro and says that the declaration has not storage class or type specifier.
I’m not sure why that would break it, but I would say that you probably don’t need to include this in your header file. The usual way is to include it within your .cpp file, and in the .h you declare the variable with forward declaration
i.e. you put class in front of the variable like this:
class UPhysicsHandleComponent* MyComponent
or you declare the class at the top of your .h file:
//includes here
class UPhysicsHandleComponent;
UCLASS(....)
....
This basically tells the compiler that ‘I have a class called UPhysicsHandlerComponent’, so consider that an acceptable type for now and we’ll get the actual class definition later in the compilation process.
I found that running project → rescan solution will often clear up these issues between the compiler and Unreal. I’m still confused as to which #includes to place where. Usually I include any class that is used by a predeclared variable at the top of the header file, but before the generated.h. Any class used by variables declared only in the cpp, goes at the top of the cpp file, but after the #include .h