Hey everyone I have a little problem with my replication client → server
here you can find my c++ characterVr I can see the server move but not my client on the server its Lqn game and I can’t use VrExtension it for school projects thx if you have responded
"#pragma region Behavior
ACharacterVR::ACharacterVR()
{
PrimaryActorTick.bCanEverTick = true;
bReplicates = true;
bAlwaysRelevant = true;
VRRoot = CreateDefaultSubobject<USceneComponent>(TEXT("VRRoot"));
RootComponent = VRRoot;
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
CameraComponent->bLockToHmd = true;
CameraComponent->SetupAttachment(RootComponent);
LeftController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftController"));
LeftController->SetTrackingMotionSource(MotionSourceName::Left);
LeftController->SetupAttachment(RootComponent);
WidgetInteractionLeft = CreateDefaultSubobject<UWidgetInteractionComponent>(TEXT("WidgetInteractionLeft"));
WidgetInteractionLeft->SetupAttachment(LeftController);
LeftHand = CreateDefaultSubobject<UHandComponentVr>(TEXT("LeftHand"));
LeftHand->SetupAttachment(LeftController);
LeftHand->bIsMirrored = true;
LeftControllerAim = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftControllerAim"));
LeftControllerAim->SetTrackingMotionSource(MotionSourceName::LeftAim);
LeftControllerAim->SetupAttachment(RootComponent);
RightController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightController"));
RightController->SetTrackingMotionSource(MotionSourceName::Right);
RightController->SetupAttachment(RootComponent);
WidgetInteractionRight = CreateDefaultSubobject<UWidgetInteractionComponent>(TEXT("WidgetInteractionRight"));
WidgetInteractionRight->SetupAttachment(RightController);
RightHand = CreateDefaultSubobject<UHandComponentVr>(TEXT("RightHand"));
RightHand->SetupAttachment(RightController);
RightHand->bIsMirrored = true;
RightControllerAim = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightControllerAim"));
RightControllerAim->SetTrackingMotionSource(MotionSourceName::RightAim);
RightControllerAim->SetupAttachment(RootComponent);
TeleportComponent = CreateDefaultSubobject<UTeleportComponent>(TEXT("TeleportComponent"));
TeleportComponent->SetupAttachment(RightControllerAim);
}
// Called when the game starts or when spawned
void ACharacterVR::BeginPlay()
{
Super::BeginPlay();
GameUserSettings = Cast(GEngine->GetGameUserSettings());
if (!GameUserSettings)
{
UE_LOG(LogTemp, Error, TEXT(“Game user settings is null”));
return;
}
MovementMode = GameUserSettings->GetVRMovementMode();
if (UVRStatics::IsHMDActive())
{
UHeadMountedDisplayFunctionLibrary::SetTrackingOrigin(EHMDTrackingOrigin::Stage);
}
TeleportComponent->SetArcFXSystem(TeleportFX);
}
// Called to bind functionality to input
void ACharacterVR::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
if (!InputMappingContext)
{
UE_LOG(LogInput, Error, TEXT("InputMappingContext is not set up for the player"));
return;
}
if (!InputConfig)
{
UE_LOG(LogInput, Error, TEXT("InputConfig data asset is not set up for the player"));
return;
}
// add default mapping context
const APlayerController* PlayerController = GetController<APlayerController>();
UEnhancedInputLocalPlayerSubsystem* InputSubsystem = PlayerController->GetLocalPlayer()->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();
InputSubsystem->AddMappingContext(InputMappingContext, 0);
// set actions up
UEnhancedInputComponent* EnhancedInput = Cast<UEnhancedInputComponent>(PlayerInputComponent);
EnhancedInput->BindAction(InputConfig->Move, ETriggerEvent::Triggered, this, &ACharacterVR::Move);
EnhancedInput->BindAction(InputConfig->Look, ETriggerEvent::Triggered, this, &ACharacterVR::Look);
EnhancedInput->BindAction(InputConfig->SnapTurn, ETriggerEvent::Triggered, this, &ACharacterVR::SnapTurn);
EnhancedInput->BindAction(InputConfig->Teleport, ETriggerEvent::Started, this, &ACharacterVR::StartTeleport);
EnhancedInput->BindAction(InputConfig->Teleport, ETriggerEvent::Completed, this, &ACharacterVR::FinishTeleport);
EnhancedInput->BindAction(InputConfig->CancelTeleport, ETriggerEvent::Triggered, this, &ACharacterVR::CancelTeleport);
LeftHand->SetupInput(EnhancedInput, InputConfig, InputSubsystem, EControllerHand::Left);
RightHand->SetupInput(EnhancedInput, InputConfig, InputSubsystem, EControllerHand::Right);
}
void ACharacterVR::OnUserSettingsChanged()
{
if (MovementMode != GameUserSettings->GetVRMovementMode())
{
if (MovementMode == EVRMovementMode::Blink)
{
CancelTeleport();
}
MovementMode = GameUserSettings->GetVRMovementMode();
}
}
void ACharacterVR::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (!HasAuthority())
{
UpdateVRTransforms();
}
}
#pragma endregion
#pragma region MovementVR
void ACharacterVR::Move(const FInputActionInstance& Instance)
{
if (UVRStatics::IsHMDActive() && MovementMode == EVRMovementMode::Blink)
{
return;
}
const FVector2D Vector = Instance.GetValue().Get<FVector2D>();
AddMovementInput(GetMovementForwardVector(), Vector.X);
AddMovementInput(GetMovementRightVector(), Vector.Y);
}
void ACharacterVR::Look(const FInputActionInstance& Instance)
{
const FVector2D Vector = Instance.GetValue().Get();
AddControllerPitchInput(Vector.Y);
AddControllerYawInput(Vector.X);
}
"
here how i replicate "#pragma region Replicate
void ACharacterVR::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ACharacterVR, ReplicatedHeadTransform);
DOREPLIFETIME(ACharacterVR, ReplicatedLeftControllerTransform);
DOREPLIFETIME(ACharacterVR, ReplicatedRightControllerTransform);
}
void ACharacterVR::UpdateVRTransforms()
{
UE_LOG(LogTemp, Warning, TEXT(“Client : Envoi de la mise à jour des mains/tête au serveur”));
if (!IsLocallyControlled()) return;
Server_UpdateHeadTransform(CameraComponent->GetComponentTransform());
Server_UpdateLeftControllerTransform(LeftController->GetComponentTransform());
Server_UpdateRightControllerTransform(RightController->GetComponentTransform());
}
void ACharacterVR::OnRep_HeadTransform()
{
CameraComponent->SetWorldTransform(ReplicatedHeadTransform);
}
void ACharacterVR::OnRep_LeftControllerTransform()
{
LeftController->SetWorldTransform(ReplicatedLeftControllerTransform);
}
void ACharacterVR::OnRep_RightControllerTransform()
{
RightController->SetWorldTransform(ReplicatedRightControllerTransform);
}
void ACharacterVR::Server_UpdateHeadTransform_Implementation(const FTransform& NewTransform)
{
if (GetOwner() != GetController()) // Vérifie si le propriétaire est le bon PlayerController
{
UE_LOG(LogTemp, Warning, TEXT(“Server_UpdateHeadTransform: Mauvais propriétaire !”));
return;
}
ReplicatedHeadTransform = NewTransform;
}
bool ACharacterVR::Server_UpdateHeadTransform_Validate(const FTransform& NewTransform)
{
return true; // Ajoutez une validation ici si nécessaire
}
void ACharacterVR::Server_UpdateLeftControllerTransform_Implementation(const FTransform& NewTransform)
{
ReplicatedLeftControllerTransform = NewTransform;
}
bool ACharacterVR::Server_UpdateLeftControllerTransform_Validate(const FTransform& NewTransform)
{
return true;
}
void ACharacterVR::Server_UpdateRightControllerTransform_Implementation(const FTransform& NewTransform)
{
ReplicatedRightControllerTransform = NewTransform;
}
bool ACharacterVR::Server_UpdateRightControllerTransform_Validate(const FTransform& NewTransform)
{
return true;
}
#pragma endregion" my character is posses and the RPC function is call