Unrecognized type 'FLifetimeProperty'

I keep getting: Unrecognized type ‘FLifetimeProperty’

When looking online all I found was to include “Net/UnrealNetwork.h”

output

1>------ Build started: Project: TwinStickShooter, Configuration: Development_Game x64 ------
1>  Parsing headers for TwinStickShooter
1>  I:/BSGD/Unreal/TwinStickShooter/Source/TwinStickShooter/BaseCharacter.h(27) : Unrecognized type 'FLifetimeProperty'
1>Error : Failed to generate code for TwinStickShooter - error code: OtherCompilationError (5)
1>  UnrealHeaderTool failed for target 'TwinStickShooter' (platform: Win64, module info: I:\BSGD\Unreal\TwinStickShooter\Intermediate\Build\Win64\TwinStickShooter\Development\UnrealHeaderTool.manifest).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""I:\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" TwinStickShooter Win64 Development "I:\BSGD\Unreal\TwinStickShooter\TwinStickShooter.uproject" -rocket" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Error List:

Error	1	error code: OtherCompilationError (5)	I:\BSGD\Unreal\TwinStickShooter\Intermediate\ProjectFiles\Error
Error	2	error MSB3073: The command ""I:\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" TwinStickShooter Win64 Development "I:\BSGD\Unreal\TwinStickShooter\TwinStickShooter.uproject" -rocket" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38

ABaseCharacter.h

#pragma once
#include "Net/UnrealNetwork.h"
#include "GameFramework/Character.h"
#include "BaseCharacter.generated.h"

UCLASS(Blueprintable)
class TWINSTICKSHOOTER_API ABaseCharacter : public ACharacter
{
	GENERATED_BODY()
public:

	//Health
	UPROPERTY(Replicated, BlueprintReadWrite, EditAnywhere, Category = "Base Character")
		float Health = 100;
	//isDead
	UPROPERTY(Replicated, BlueprintReadOnly, VisibleAnywhere, Category = "Base Character")
		bool isDead = false;
	//Calc Death
	virtual void CalculateDead();
	//Calc health
	UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = "Base Character")
		virtual void CalcualteHealth(float delta);

	UFUNCTION()
		virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty> & OutLifetimeProps) const override;

#if WITH_EDITOR
	//Editor-centric code for changing  property
	virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif

	ABaseCharacter();

	// Sets default values for this character's properties
	ABaseCharacter(const class FPostConstructInitializeProperties& PCIP);

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	// Called every frame
	virtual void Tick(float DeltaSeconds) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

};

ABaseCharacter.cpp

#include "TwinStickShooter.h"
#include "BaseCharacter.h"

ABaseCharacter::ABaseCharacter()
{

}
// Sets default values
ABaseCharacter::ABaseCharacter(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP)
{
		bReplicates = true;
		// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
		PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void ABaseCharacter::BeginPlay()
{
	Super::BeginPlay();

}

// Called every frame
void ABaseCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void ABaseCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	Super::SetupPlayerInputComponent(InputComponent);

}

//Implement Calc Health
void ABaseCharacter::CalcualteHealth(float delta)
{
	Health += delta;
	CalculateDead();
}

//Implement Calc Dead
void ABaseCharacter::CalculateDead()
{
	if (Health <= 0)
	{
		isDead = true;
	}
	else
	{
		isDead = false;
	}
}

//Implment PostEditChangedProperty
#if WITH_EDITOR
void ABaseCharacter::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
	isDead = false;
	Health = 100;

	Super::PostEditChangeProperty(PropertyChangedEvent);
	CalculateDead();
}


void ABaseCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty> & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
	DOREPLIFETIME(ABaseCharacter, Health);
	DOREPLIFETIME(ABaseCharacter, isDead);
}
#endif

this non-UObject class is declered in “UObject/CoreNet.h” according to API refrence

I included the header file “Runtime/CoreUObject/Public/UObject/CoreNet.h” but I am still getting the error. Intellisense recognizes it, I can hit f12 and go to the declaration.

All I had to do was include “Runtime/Engine/Public/Net/UnrealNetwork.h”.

If you’re still having problems after that, check your #if WITH_EDITOR statement, which currently encases the GetLifetimeReplicatedProps definition.

I did not notice that it was in the #if WITH_EDITOR section, I will move it tonight, thanks for noticing that.

Hey -

It appears that the GetLifetimeReplicatedProps function that you try to override is not set as virtual inside Character.h. This, along with the FLifetimeProperty class not being a UCLASS is likely the issue. If you are using a source version of the engine you can edit the Character.h GetLifetimeReplicatedProps() function or edit CoreNet.h to make the FLifetimeProperty class a UCLASS. If you are using the binary then you would have to call the parent implementation of the function with ACharacter::GetLifetimeReplicatedProps() directly.

Cheers

I finally got it to compile :smiley:

Thank you for all the help everyone.

Actor.h and ACharacter.h

		virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty> & OutLifetimeProps) const override;

ABaseCharacter.h

#pragma once

#include "GameFramework/Character.h"
#include "Net/UnrealNetwork.h"
#include "BaseCharacter.generated.h"

UCLASS(Blueprintable)
class TWINSTICKSHOOTER_API ABaseCharacter : public ACharacter
{
	GENERATED_BODY()


public:

	//Health
	UPROPERTY(Replicated, BlueprintReadWrite, EditAnywhere, Category = "Base Character")
		float Health = 100;
	//isDead
	UPROPERTY(Replicated, BlueprintReadOnly, VisibleAnywhere, Category = "Base Character")
		bool isDead = false;
	//Calc Death
	virtual void CalculateDead();
	//Calc health
	UFUNCTION(BlueprintCallable, Category = "Base Character")
		virtual void CalcualteHealth(float delta);

		void GetLifetimeReplicatedProps(TArray<FLifetimeProperty> & OutLifetimeProps) const override;

#if WITH_EDITOR
	//Editor-centric code for changing  property
	virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif

	// Sets default values for this character's properties
	ABaseCharacter();

	ABaseCharacter(const class FObjectInitializer& PCIP);

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	// Called every frame
	virtual void Tick(float DeltaSeconds) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

};

ABaseCharacter.cpp

#include "TwinStickShooter.h"
#include "BaseCharacter.h"


// Sets default values
ABaseCharacter::ABaseCharacter()
{
	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

ABaseCharacter::ABaseCharacter(const class FObjectInitializer& PCIP) : Super(PCIP)
{
	bReplicates = true;
	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void ABaseCharacter::BeginPlay()
{
	Super::BeginPlay();

}

// Called every frame
void ABaseCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void ABaseCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	Super::SetupPlayerInputComponent(InputComponent);

}

//Implement Calc Health
void ABaseCharacter::CalcualteHealth(float delta)
{
	Health += delta;
	CalculateDead();
}

//Implement Calc Dead
void ABaseCharacter::CalculateDead()
{
	if (Health <= 0)
	{
		isDead = true;
	}
	else
	{
		isDead = false;
	}
}

void ABaseCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty> & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
	DOREPLIFETIME(ABaseCharacter, Health);
	DOREPLIFETIME(ABaseCharacter, isDead);
}

//Implment PostEditChangedProperty
#if WITH_EDITOR
void ABaseCharacter::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
	isDead = false;
	Health = 100;

	Super::PostEditChangeProperty(PropertyChangedEvent);
	CalculateDead();
}

#endif

I removed the Server, Reliable, WithValidation from

UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = "Base Character")
         virtual void CalcualteHealth(float delta);

because it was causing linker errors:

Error	1	error LNK2005: "public: virtual void __cdecl ABaseCharacter::CalcualteHealth(float)" (?CalcualteHealth@ABaseCharacter@@UEAAXM@Z) already defined in BaseCharacter.cpp.obj	I:\BSGD\Unreal\TEST\Intermediate\ProjectFiles\TwinStickShooter.generated.cpp.obj
Error	2	error LNK2001: unresolved external symbol "public: virtual bool __cdecl ABaseCharacter::CalcualteHealth_Validate(float)" (?CalcualteHealth_Validate@ABaseCharacter@@UEAA_NM@Z)	I:\BSGD\Unreal\TEST\Intermediate\ProjectFiles\BaseCharacter.cpp.obj
Error	3	error LNK2001: unresolved external symbol "public: virtual bool __cdecl ABaseCharacter::CalcualteHealth_Validate(float)" (?CalcualteHealth_Validate@ABaseCharacter@@UEAA_NM@Z)	I:\BSGD\Unreal\TEST\Intermediate\ProjectFiles\TwinStickShooter.generated.cpp.obj
Error	4	error LNK2001: unresolved external symbol "public: virtual void __cdecl ABaseCharacter::CalcualteHealth_Implementation(float)" (?CalcualteHealth_Implementation@ABaseCharacter@@UEAAXM@Z)	I:\BSGD\Unreal\TEST\Intermediate\ProjectFiles\BaseCharacter.cpp.obj
Error	5	error LNK2001: unresolved external symbol "public: virtual void __cdecl ABaseCharacter::CalcualteHealth_Implementation(float)" (?CalcualteHealth_Implementation@ABaseCharacter@@UEAAXM@Z)	I:\BSGD\Unreal\TEST\Intermediate\ProjectFiles\TwinStickShooter.generated.cpp.obj
Error	6	error LNK1120: 2 unresolved externals	I:\BSGD\Unreal\TEST\Binaries\Win64\TwinStickShooterServer.exe	1

Do I need to include those for the function to be called on the server?