Client Pawn Rotation overriden by last server data 2 frames out of 3 in multiplayer

Hi,

Rotating a pawn in multiplayer as the client using the bReplicateMovement = true and AddActorLocationRotation (Or AddActorWorldRotation, or SetActorRotation, it doesn’t matter) produces a much slower effect than is expected most of the time.

I say “most of the time” because it depends. This happens when:

1- Totally motionless
2- When accelerating

This does NOT happen when:

1- When moving but not accelerating

After doing some experimentation and logging, it would appear that when the rotation is awfully slow, it’s because two ticks out of three, (at 60 ticks per second), the ROLE_Autonomous Client’s pawn rotation is reverted back to that of the last received rotation from the server.

One tick out of three, the rotation happens just fine because the server is receiving it and so there is no need to rollback.

The very slow rotation can therefore be explained by the fact that it is going 1/3rd of the expected speed, because only a third of the frames actually matter. Two frames are spent doing a slight rotation and immediately rolling back, after the pawn tick and before the next pawn tick.

Hey Altrue,

I’ve tested this on my end, but I’m not seeing the same results. I may be overlooking something that you have in your setup, however. Could you provide me with a detailed list of repro steps or a simplified test project that showcases this issue? Also, feel free to modify the project I sent over in your other thread to showcase this issue as well.

Thanks!

I have the same issue. And I posted it here

To reproduce this issue:

  • Start with an empty project and a new Character class.
  • In Tick() function, use SetActorRotation(FRotator(0.f, GetActorRotation().Yaw + 5, 0.f)) - to rotate actor around Z-axis by 5 degrees every frame.
  • Print out the current actor rotation yaw every frame.
  • Play in editor with dedicated server option enabled.
  • Check the rotation printed, you will notice that character rotation yaw doesn’t increase by 5 every frame. It happens like once every 3 frames and doesn’t update 2 out of 3 times.
  • Make sure the game is not running at low fps. The rotation works fine on low fps (noticeable at 60 fps+).
  • Also make sure the character is not owned by a listen server, that doesn’t have any issue.

The same thing will happen if you call a server RPC from client to set actor rotation. As long as the character is owned by client, the rotation doesn’t get updated every frame.

I can upload the project if needed.

Have you managed to resolve this issue or find a workaround on this?
I am facing the same issue. I need to rotate a character on client every frame but the rotation of characters owned by client don’t update about 2 out of 3 frames

Did some digging and found that this can be prevented by calling GetCharacterMovement()->FlushServerMoves() before calling SetActorRotation().
This has resolved my issue for now, though I am not sure if it will mess up anything else related to movement replication. I’ll see.

Hello,

If you’re still experiencing this issue in 4.19 or the 4.20 Preview, please feel free to submit a report using the Bug Submission Form if you haven’t already, and we’ll be glad to take a look.

Thanks,

Sean