Faulty network prediction

Hello,

I’ve been testing my multiplayer game and the networking seems to be working fine apart from the prediction being wildly off, and subsequently making the game unplayable.
I’ve done several runs of optimizing the network code using the net profiler, and it’s pretty efficient now. Playing with a friend across the atlantic gives about 100ms ping. Which is perfectly acceptable for multiplayer.

However the prediction causes the clients to wildly jump around erratically. After carefully observing the behaviour it seems the server is registering when a character stops moving, or makes a sudden change in direction, causing it to think the player carried on in some direction. When it later checks it finds the player isn’t in the right place, and makes a huge correction, often involving no interpolation whatsoever.

The thing is. I’ve never touched the prediction code, and I have no clue what could be causing this. I thought Epics code would be solid. The characters in our game move pretty fast, but it’s still within the realms of something like UT, which isn’t unreasonable.

I’d very much like some help with this. I don’t really know what information is useful in solving this, so if you’d like to see code for something do ask. Note that I’ve never touched the CharacterMovementComponent code, so I can’t show you anything useful there. I’d be willing to send someone the project, however we have customized the engine a little and so it’d be awkward to send our engine and the game and all it’s files.

Here’s a log file from the server of a recent playtest, it shows all the client errors. https://dl.dropboxusercontent.com/u/53792213/HitBoxTesting.log

Thanks for any and all help you provide.

Hi Constan7ine,

How much is the correction and at what speed do your characters move when this happens? If they move by 1 meter per second, you have to accept at least 100 cm error on 100 ping and that can look awkward when the correction happens. You can accept larger errors but it’s a tradeoff.

I wouldn’t call UE4’s stock replication code bad but it’s definatly not state of the art and it’s probably intended for very general applications. You could look at Unreal Tournament’s movement replication code, it’s different and (IMO) better than what you find in stock.

The walk speed of the characters is about 550 units. I assume this is unreal units, I’m not sure how that translate to metric.

Unreal tournament is a great idea. Since I’m otherwise out of ideas I’m going to try out using their networking code and see if it works. Thanks for your help.

How are you applying movement to the character?

I am currently struggling with some minor stutter issues while strafing… which I believe is due to how I am applying rotation directly to capsule (outside of charactercomponent). This breaks the prediction in these instances.

Like this, it’s pretty standard I think. Not a lot to go wrong:


void ABBCharacter::MoveForward(float Value)
{
	if (Value != 0.0f)
	{
		// add movement in that direction
		AddMovementInput(GetActorForwardVector(), Value);
	}
}

void ABBCharacter::MoveRight(float Value)
{
	if (Value != 0.0f)
	{
		// add movement in that direction
		AddMovementInput(GetActorRightVector(), Value);
	}
}

void ABBCharacter::TurnAtRate(float Rate)
{
	if (Rate != 0 && Controller)
	{
		Cast<ABBPlayerController>(Controller)->bIsControllerInUse = true;
	}
	// calculate delta for this frame from the rate information
	AddYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}

void ABBCharacter::LookUpAtRate(float Rate)
{
	if (Rate != 0 && Controller)
	{
		Cast<ABBPlayerController>(Controller)->bIsControllerInUse = true;
	}
	// calculate delta for this frame from the rate information
	AddPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}

An update on my problem. I copied over and integrated most of UT’s movement replication code into our game to see if it would help. It didn’t
We just tested playing across the Atlantic with about 70ms ping, and the characters still jump around and teleport large distances every few seconds. I’m now completely at a loss.

All I’ve learned is it can’t be core prediction and movement code that’s causing this problem. There must be something else, somewhere that ******** everything up.

Any ideas will receive my eternal gratitude.

Hello all,

I hate to be that guy to bump an old post, but our game is being significantly delayed because of this issue which we’ve still been unable to solve. Absolutely any help would be appreciated and we’ll think of a reward if anyone can solve it.

Thanks

I’ll provide any information to try help that may be required. If someone even has time to look at our code in full we’ll do that.