The reason i had to include LibertyCharacter.h in LibertyHealthComponent.h is because of unable to forward declare USTRUCT: FLibertyGeneralMovementSettings which is present in LibertyCharacter.h.
LibertyCharacter.h:
// Forward declares
class ULibertyHealthComponent;
enum class ELibertyDeathState : uint8;
USTRUCT(BlueprintType)
struct FLibertyGeneralMovementSettings
{
GENERATED_BODY()
};
#include "LibertyCharacter.h"
// Tried to do this earler (instead of including LibertyCharacter.h and then including in .cpp) but didnt work. This was the initial problem.
struct FLibertyGeneralMovementSettings;
Seeing that FLibertyGeneralMovementSettings is used in more than one place should push you to atomize it by extracting it to it’s on file (maybe a common struct file or a movement file). Strip out the dependency then you can forward declare in both files.
You can but it depends where you forward declared it.
If you want the forward declaration to span the whole file then put it above the UClass of the main file you are in. If you just forward declare inside of the class properties then you have to keep forward declaring even inside of UFunctions over and over again.
So it’s best to declare it up top similarly like with delegates.
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Logging/LogMacros.h"
#include "Misc/DateTime.h"
#include "HAL/PlatformTime.h"
#include "LibertyCharacter.generated.h"
class USpringArmComponent;
class UCapsuleComponent;
class UCameraComponent;
class UArrowComponent;
class UInputMappingContext;
class UInputAction;
class ULibertyMovementComponent;
enum class ELibertyDeathState : uint8;
class ULibertyHealthComponent;
struct FInputActionValue;
UCLASS(config=Game)
class ALibertyCharacter : public ACharacter
{
GENERATED_BODY()
public:
//UFUNCTION()
virtual void OnDeathStateChanged(ULibertyHealthComponent* HealthComponent, ELibertyDeathState OldDeathState, ELibertyDeathState NewDeathState);
};
The compiler assumes it is an int, and throws errors.
I think this might be UENUM and UFUNCTION limitation of some sort? Probably to do with UENUM size, the compiler don’t know its size when passing as a parameter to a UFUNCTION?
Because without UFUNCTION() over OnDeathStateChanged, no problems!
I see, you are using a seperate file for enums, thats the only difference i see in your code and mine, and this might just be the only solution (atleast for now).
I am not going to dig around more about this, i have been doing that for a minute! I appreciate you man, thanks for your precious time.