I have a APawn controlled by a player controller on the server and the client.
Now I dont have any movement components, I just use SetActorLocation and SetActorRotation to move the pawn around.
In a network game, the server’s pawn is correctly rotated and positioned on the client, but the client is not correctly rotated and positioned on the server
In:
void AActor::GatherCurrentMovement()
I notice the server will gather the position and location and send that to the client, so I would think the client should at least jump to where the server thinks the actor should be, but this does not appear to be happening.
I don’t know if this provides anything but I had a similar problem (Actually I still have it, just “fixed” it with a workaround):
My pawn’s (not characters that can use the cool CharacterMovementComponent ) position would slowly differ between server and client when moving, it stacked up more and more over time. To fix that I used a custom FRotator/FVector containing position/rotation and saved the server position/rotation in it, replicate it to the clients and use a RepNotify to override it. I still do not know why and how this happened, but maybe someone has a solution/idea what is happening!
yeah replicate movement is enabled, and I also tried setting bAlwaysRelevant = true
It looks like AActor::OnRep_ReplicatedMovement is being called correctly on those actors the server is responsible for controlling, just not for the actor the connected client is responsible for controlling :-/
Edit:
hrmm I have a wild hunch, could it be that, the client sends the data to the server, the server then doesnt send any data back as it sees that the data has not changed somehow? this wouldnt really seem to be a valid theory as the actor on the client is not related to the actor on the server, both are out of sync in regard to position and location.
on the client computer the pawn the client is controlling has
RemoteRole = 2 (auto proxy)
Role = 3 (authority)
I see the ut4 code only sets this in 2 places:
UChildConnection::HandleClientPlayer
and
UNetConnection::HandleClientPlayer
I figure its one of these causing the problem.
The problem is not with the pawn the server is controlling (this is in sync and working), the problem is with the pawn the client is controlling (this is out of sync).
I’d love to see this in blueprint. I found out the hard way you can’t use “replicate movement” in the pawn. I’m looking to do what you just mentioned or go down the rabbit hole of network prediction plugin? Idk