Download

Is this a potential optimization that can be made to ReplicatedMovement?

First of all, forgive me if I’m missing a step much deeper down in Engine code that handles all this for us - I felt this was potentially worth pointing out just in case it went by unnoticed :slight_smile: I have recently been reading and watching various articles and talks from a talented and knowledgeable chap called Glenn Fielder, who any physics and/or networking programmers will know from Gaffer On Games. See here:

GDC 2015 Talk
Paper / Documentation

I know from searching around that Unreal was not built with a deterministic physics simulation in mind, but I still feel it could be very suitable for my needs just using the default engine networking tools (which are by the way, really good!). My aim is to simulate up to a few thousand actors at any time over a network with an initial aim of about ten players. The game is very FPS / Vehicle-combat based but also has a strong grounding in RTS-style gameplay. My go-to title is to think of Planetside 2, but with smaller worlds and not quite so many human players. Nevertheless, it’s still a lot to simulate, especially if you want to use projectile-based weapons like me for nearly everything.

Anybody who has used the network profiler knows that ReplicatedMovement is the single biggest amount of data sent via network connection in most UE games. You can try it yourself by building out a copy of ShooterGame and watching the digits stream in. Although very suitable in a game with up to 10 players and a few bots, all the weapons are based on traces and the projectiles rarely spawn on the map, so it works well in this scenario. However, I think I might have found some room for improvement in the ReplicatedMovement part of the engine.

If you click the above link regarding documentation, one part that struck me in particular was the enormous bandwidth reduction he was able to get by being quite clever with the replication. Like Gaffer mentions, Unreal by default appears to use World Location, Orientation and Linear Velocity in order to ensure smooth interpolation between packet updates. Unreal also handles packet loss just fine even in most laggy situations, though there doesn’t appear to be any evidence of the ‘DeltaPacket’ that Gaffer also mentions, which gives him his super-reduced bandwidth.

Unreal already uses quantized data for velocity and location which helps, but I find it odd that we use ActorRotation for orientation replication - 3x 32-bit floats (a total of 96 bits for orientation replication). Fielder manages to get this down to 29-bits for orientation that still gives sufficient precision by using a Quaternion that is re-constructed from only three reduced elements at the other end. Effectively this cuts the rotation replication down to less than a third of it’s original size. Although this seems like a tiny change, all these little changes grouped together make for much larger end-gains.

Also while I don’t fully understand Fielders technique behind DeltaPackets, I understand the notion of them. The resulting simulation reduces bandwidth considerably by being much smarter about the data that is sent. Is this also something Unreal could benefit from in the long run? Like I say, the engines networking is great as is, but any time spent on optimization in networking is time well spent in my opinion!

I have not gotten this deep into networking to care about this level of optimization but sounds like ReplicatedMovement needs some improvements overall.

Personally I’m experiencing some network lag/jittering when pawns are standing on a fast moving vehicle that (I’m guessing) has do with movement prediction so this is also something that worth a look at since we are talking about the ReplicatedMovement :stuck_out_tongue:

But I should probably make a separate post about this, since it looks like I won’t be able to solve this on my own (also not to hijack this thread).