Hi all, i have some issue with my player controller. When i’m tring to replicate a FRotator, the authority give me always an 0 filled value.
This is my code
// AdvController.h
UPROPERTY(Replicated, BlueprintReadOnly, Category = "Controller|FreeLook")
FRotator ViewRotation;
UFUNCTION(BlueprintCallable, Category = "Pawn")
void SetViewRotation(const FRotator& NewRotation);
UFUNCTION(Server, Reliable, WithValidation)
void ServerSetViewRotation( const FRotator& NewRotation );
// AdvController.cpp
#include "UnrealNetwork.h"
AAdvPlayerController::AAdvPlayerController(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
bReplicates = true;
}
void AAdvPlayerController::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AAdvPlayerController, ViewRotation);
}
void AAdvPlayerController::SetViewRotation(const FRotator& NewRotation)
{
ViewRotation = NewRotation;
if (Role < ROLE_Authority)
{
ServerSetViewRotation(NewRotation);
}
}
void AAdvPlayerController::ServerSetViewRotation_Implementation( const FRotator& NewRotation )
{
SetViewRotation(NewRotation);
}
bool AAdvPlayerController::ServerSetViewRotation_Validate( const FRotator& NewRotation )
{
return true;
}
void AAdvPlayerController::UpdateRotation(float DeltaTime)
{
// ..
// ..
// ..
// ..
// ..
if (Some check that will return true)
{
SetViewRotation(NewViewRotation);
}
// ..
// ..
// ..
// ..
// ..
}
But the server return always a zero rotator. There is the possibility that the controller Rotation is not replicated?
Where is the problem? Thanks