How can I use VRRoot in multiplayer?

I’m trying to apply VRRoot to my multiplayer project.
This is my code.

BP_VRCharacter

VRCharacter.h

void CalculateHMDToCharLocation();

void HMDSyncLocation();

UFUNCTION(Server, Unreliable)
	void Server_HMDSyncLocation(FVector NewLocation);

FVector HMDToCharLocation = FVector::ZeroVector;

VRCharacter.cpp

void AVRCharacter::Tick(float DeltaTime)
{
	CalculateHMDToCharLocation();
	HMDSyncLocation();

	Super::Tick(DeltaTime);
}

void AVRCharacter::CalculateHMDToCharLocation()
{
	FVector NewCameraOffset = Camera->GetComponentLocation() - GetActorLocation();
	NewCameraOffset.Z = 0;
	HMDToCharLocation = NewCameraOffset;
	Server_HMDSyncLocation(NewCameraOffset);
}

void AVRCharacter::HMDSyncLocation()
{
	AddActorWorldOffset(HMDToCharLocation);
	VRRoot->AddWorldOffset(-HMDToCharLocation);
}

void AVRCharacter::Server_HMDSyncLocation_Implementation(FVector NewLocation)
{
	HMDToCharLocation = NewLocation;
}

I didn’t understand the multiplayer lecture well, but I wrote the code with my stupid brain.

It works when playing Play as Client with two players, but there is jittering.

The client (Client 0) that moves the HMD moves with jittering,
but client 1 looking at it seems to be moving well.

I’ve been thinking about solving this problem for two days, but I can’t.
Any advice will be appreciated. Help me…

1 Like

You are going to get jittering - this is something that is looked at later in the multiplayer course but is way beyond the VR course.

We can’t really cover this in either the VR course or the Multiplayer course. VR adds an extra layer of complexity.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms