So basically I’ve done everything that was told in the docs: Property Replication | Unreal Engine Documentation
Uproperty declaration:
UPROPERTY(replicated, EditAnywhere, Category = Replication)
bool bReplicatedVar;
In the constructor bReplicates flag is set to true.
AReplicatedActor::AReplicatedActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
bReplicates = true;
}
And I’ve implemented GetLifetimeReplicatedProps as well.
void AReplicatedActor::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AReplicatedActor, bReplicatedVar);
}
#include <EngineGlobals.h>
#include <Runtime/Engine/Classes/Engine/Engine.h>
#define DEBUG_FUNCTION_KEY -1
#define DEBUG_SERVER_KEY 2
#define DEBUG_CLIENT_KEY 3
#define DEBUG_USUAL_KEY 4
#define DEBUG_U_LOG(text) if (GEngine) GEngine->AddOnScreenDebugMessage(DEBUG_USUAL_KEY, 0.2f, FColor::Orange,text)
#define DEBUG_F_LOG(text) if (GEngine) GEngine->AddOnScreenDebugMessage(DEBUG_FUNCTION_KEY, 0.2f, FColor::Blue,text)
#define DEBUG_S_LOG(text) if (GEngine && Role == ROLE_Authority) GEngine->AddOnScreenDebugMessage(DEBUG_SERVER_KEY, 0.2f, FColor::Red,text)
#define DEBUG_C_LOG(text) if (GEngine && Role < ROLE_Authority) GEngine->AddOnScreenDebugMessage(DEBUG_CLIENT_KEY, 0.2f, FColor::White,text)
void AReplicatedActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
fDeltaTime += DeltaTime;
if (fDeltaTime >= 3.0f && Role == ROLE_Authority)
bReplicatedVar = true;
DEBUG_U_LOG(FString::SanitizeFloat(fDeltaTime));
DEBUG_S_LOG(bReplicatedVar ? TEXT("true") : TEXT("false"));
DEBUG_C_LOG(bReplicatedVar ? TEXT("true") : TEXT("false"));
}
Dont know what is going on and why the property is not replicating. I will appreciate any reply. I’m currently at that point anything is helpful.