Download

Client-side only origin shifting in multiplayer

Hello.

I am trying to implement client-side only world origin shifting. So, server always uses 0,0,0, but clients time to time sets origin to own location (to allow smooth animation and client-side bullets simulation).

So, to achive it, I use:


void AAbstractCharacter::PostNetReceive()
{		
     if  (!GetWorld()->isServer()) {
		ReplicatedMovement.Location.X = ReplicatedMovement.Location.X - GetWorld()->OriginLocation.X;
		ReplicatedMovement.Location.Y = ReplicatedMovement.Location.Y - GetWorld()->OriginLocation.Y;
		ReplicatedMovement.Location.Z = ReplicatedMovement.Location.Z - GetWorld()->OriginLocation.Z;
     }
}

So, after world origin shifts on client - client starts to modify coordinates received from server by own world origin, so, visually all AAbstractCharacter objects keeps their position relativelty to static actor (like landscape). But except locally controlled AAbstractCharacter… PostNetReceive is not called for locally controller character - and I can’t find place where local player position are received from server…

So, how currently contolled Character position are received from server (to able to hook modify them on receive)?

UPDATE:
Was able to figure it out - https://forums.unrealengine.com/showthread.php?109335-Pull-Request-World-Origin-Shifting-in-MP

Assuming that you have movement replicating properly and are inheriting from ACharacter, OnRep_ReplicatedMovement() is called when movement is replicated.

It seems like it is not called too… Called for remotely controlled character, but not for the local.

Oh I see… you can look deeper into the character’s movement component. I believe that the server will notify the local player only if the server corrects the clients requested move. Otherwise the movement is applied client side.