Interpolation movement

Hi I’m beginner of ue4 network programming.

I am making multiplay shooting game.

A pawn in my game is replicated actor, so it run perfectly no problem with replicates location and rotation.

but my problem is when over 6 players connected on server. other player movement look like teleport.

I want to look like other client move smoothly.

this is my pawn update code

MyPawn::Tick(float DeltaTime)
{
if (IsLocallyControlled())
{
FTransform t = GetActorTransform();

	FVector _location = t.GetLocation();
	FRotator _rotation = FRotator(t.GetRotation());

	FVector _replocation = Rep_PawnTransform.GetLocation();
	FRotator _reprotation = FRotator(Rep_PawnTransform.GetRotation());

	float length = fabs((_location - _replocation).Size());

	if (length > LocationUpdateOffset && !bSyncLocationToServer)
	{
		ServerRPCMovement(t);
		bSyncLocationToServer = true;
	}
	else
	{
		bSyncLocationToServer = false;
	}

	float angle = acosf(FVector::DotProduct(_rotation.Vector(), _reprotation.Vector())) * (180.0f / PI);

	if (angle > RotationUpdateOffset && !bSyncRotationToServer)
	{
		ServerRPCMovement(t);
		bSyncRotationToServer = true;
	}
	else
	{
		bSyncRotationToServer = false;
	}
}
else
{			
	FVector currentLocation = GetActorLocation();
	FVector targetLocation = Rep_PawnTransform.GetLocation();

	FVector _repLocation;
	_repLocation = FMath::VInterpConstantTo(GetActorLocation(), Rep_PawnTransform.GetLocation(), DeltaTime, _LocationInterpSpeed);

	FRotator currentRotation = GetActorRotation();
	FRotator targetRotation = FRotator(Rep_PawnTransform.GetRotation());

	FRotator _repRot;
	targetRotation.Yaw = FRotator::NormalizeAxis(targetRotation.Yaw);
	_repRot = FMath::RInterpConstantTo(GetActorRotation(), FRotator(Rep_PawnTransform.GetRotation()), DeltaTime, _RotationInterpSpeed);

	SetActorLocation(_repLocation);
	SetActorRotation(_repRot);
}

}

Do I must fix this code? or other way for smooth movement.

help me.

Movement component on pawns and characters automatically replicate and apply interpolation for it to not rubberband nor teleport on clients. Are you testing this with all the clients in a single PC? If thats the case it might be that the CPU is bottlenecking due to all the clients being connected and hence optimizing out unfocused clients.

single play is good. smoothly movement well, only multiplay as 6 player in a game.

Hello!

I have some point of reference if you wish to take a look. It’s one of my git repos that may be of assistance

Multiplayer repo

thank you for share! your repos very helpful! have a nice day :slight_smile: