Pull Request - World Origin Shifting in MP


Hello everyone.

Probably everyone knows about floating point precision issues with big worlds in UE4. Sometimes some jitter (anims, camera) starts to appear only 2-4 km from origin (especially noticeable in first person games).
Since UE4 uses single point precision - only possible way to fix it is using world origin shifting. But it not works in multiplayer at the moment.

So, I am working on PR to Epic with support for origin shifting in multiplayer. Goal is to make it able to transparently use independent origins in each client/server.

Basic idea is simple as a stone: lets include sender’s origin value each time client/server going to replicate coordinates over network. In such a case receiver is able to resolve received location/origin on local origin value and work as usual.
But sending origin with every coordinate could cause some additional bandwidth usage. In order to avoid it - sender tries to resolve location/origin to zero origin before transmitting (if origin value is not too high - to avoid precision issues). With such trick it is possible send zero origin value as single bit flag (OriginIsZero).

Yes, in case of really big differences in client/sender origins it still could cause some some issues for server-driven physics. But in most of cases (animations, IK, client physics, tracing, camera location, particles) it works like a charm.

It was required to find every place where engine replicates coordinates and apply such logic there. You could get branch here - https://github.com/michail-nikolaev/UnrealEngine/tree/mp_origin_shift . I hope you able to access if you have access to Epics UE4 repo.

Currently everything is ready for about 90%.
Supported things: actor spawn, physics, character movement, pawn movement, remote proxy movement, root motion, object-based movement, blueprints functions, network relevancy, etc. Need to finish matinee data replication (what hell is it? :slight_smile: )

This is example how it works so far. Red sphere - is location of origin on each client/server. Number on top of the character - distance to world origin.


You could get test project here.
Keys: P - put origin to player location, Q, E, Z - spawn different types of object, T - teleport to distanced location, R - play root motion.

Most of the things work out of the box, but one thing you need to keep in mind: if you manually sending coordinates over network (as Vector) - engine have no idea about its semantic. So, you need to use some functions provided but it is pretty simple.
It is looks like this (converter for Vector and OriginBasedPosition):

OriginBasedPosition structure uses OriginIsZero flag optimisation out of the box.

So, I will happy if you could to try this branch (based on 4.11) on your project to test how it works (don’t forget about manual coordinate sending!). Especially interested in world composition tests.

Thanks a lot.

UPD: Official feature request ID: UE-13079
UPD2: Looks like everything is now supported, going to prepare pull request.
UPD3: Branch ready https://github.com/EpicGames/UnrealEngine/compare/release...michail-nikolaev:mp_origin_shift
UPD4: Pull Request is submitted: https://github.com/EpicGames/UnrealEngine/pull/2359
UPD5: Pull Request is updated according to EPIC review: https://github.com/EpicGames/UnrealEngine/pull/2359


Judging by the UE4 Roadmap, Epic may already have something in the works:

Not sure the status of this system, just that it may exist and conflict with yours.
May need Epic to chime in here.

Yep, but card in Wishlist/Backlog for 2 years…

When you do a Pull request - I will give you my support :slight_smile:

This is interesting, nice work!
This are the kind of things we need.

Did some tests, works fine with level streaming + world origin rebasing in MP (but dedicated server required to load all levels)

Looks great! Will test out later

1 Like

Keep it up nkey. Great work!

Awesome work @nkey.

When you say the server has to load all maps - does it need to load all the maps, or just all the maps that clients have loaded? The latter would probably be a decent optimization.

And if you want to get really deep into this, if you could make it so that separate servers can host the individual levels, that would be insanely good/useful!

This is awesome. I had been wishing this from Epic some months ago. I really hope this will get integrated into the main line.

Currently dedicates server loads all maps (even client is not on it) - it is logic in current main line.
Regarding separate servers - currently it is out of scope.

(of course)

Branch seems to be ready now: https://github.com/EpicGames/UnrealEngine/compare/release...michail-nikolaev:mp_origin_shift

@nkey - Let me know when you make the pull request :slight_smile:

@nkey - True.
Ditto on mirrored animation support :stuck_out_tongue:

Ok, sp I have no use for the feature in current project, but I’m more then happy to support the feature, as it is useful to others.
Please let me know when and what to do when the times comes.

@Kris, @HeadClot, [MENTION=887]ioFlow Studios[/MENTION], @jonimake, @n00854180t, @Mitsu, @benjamin.smith, @Hevedy, @franktech

Pull Request is submitted: https://github.com/EpicGames/UnrealEngine/pull/2359

UnrealEngine on GitHub is private.

You have to be signed in to GitHub to see that page.

Added my support to the Github comments :slight_smile:

@nkey - I am doing my part :slight_smile:

You must A. Be signed into GitHub, and B. Link your GitHub account with your Epic account (Account settings).

Regarding the PR, I would love to see this in 4.12 :stuck_out_tongue: