Merged.
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? )
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.
https://www.youtube.com/watch?v=YCx-8Gioii0
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
UPD6: MERGED!