Download

Lack of Movement Components for Networking

not sure if I’ve misunderstood this whole thread (rather likely) but I just got this working in networked multiplayer?

even physics objects replicating across the network.

Just stick a floating pawn movement component on and have a static mesh as the root component. Replicated just fine for me.

I still used physics to drive the movement of the spaceship, just switched most of the pawn movement variables to 0 apart from the max speed. I don’t do anything with the pawn movement component just literally having it attached seems to work.

I tried it with some purely physics driven spheres, works for me :slight_smile:

Unfortunately I’ve two different video capturing software and both of them won’t just record my screen, just records either the server or client window so you might just have to believe me with this static screenshot, i basically just had an input button that on press spawns a physics sphere shape, then another button to add a burst of linear physics velocity and another button for adding a burst of angular velocity.

http://i1382.photobucket.com/albums/ah256/chris_donovan1/PHYSICS_zpsazr5j9v2.png

savagebeasty: sure but that only goes as far as simple replication. With your setup you can’t make use of the other fancy features he’s referring to (lag compensation, client prediction)

thought it seemed to simple :wink:

You can simulate latency and packet loss in the editor, try 200ms lag and 50% packet loss. You’ll soon see the problem :wink:

You can also simulate network congestion and latency with clumsy: clumsy, an utility for simulating broken network for Windows Vista / Windows 7 and above

Ooo that’s kind of nice… grabbing that.

Hey guys,

this thread has become a very interesting discussion and is also a bit disappointing from a developer’s perspective because it seems that movement prediction is not a trivial task. Thanks for sharing your experience!

I tried to replicate the physics of a ball across all clients but it did not lead to satisfying results so far. The only way I could manage to keep the ball’s position in sync was to use the character class for the ball. So in fact, the ball in my game is a character and not a simple actor.
Epic’s character movement component does a very good job on this and the physics get replicated very well but there’s simply too much overhead I think. Because the replicated ball does only need some of the character’s functionality (for example the ball does not need any pathfinding logic, swimming logic or something else that the character class is capable of and that comes with the class)

So in short words: Wouldn’t it be a good idea to include different components for different purposes? So for example: If epic would include a “PhysicsPrediction” Component in UE4 that only handles the replication of simple physics objects, wouldn’t this work in 99% of the cases where you want to keep physics in sync? This would’t work for more specific needs that vary from project to project but some out of the box solution for replicated physics would be extremely sweet, wouldn’t it?

Best regards,
Daniel

Hey Daniel,

The overhead for Character Class is not much different to the overhead you would be looking at even for a simple physics ball in terms of the prediction system. You could of course save in a few areas but the underlying prediction system would still be the same, lots of loop iteration and temporary move storage. It’s also important to remember that Character Movement is not actually processed by PhysX at all. All collision rejection and movement is processed and computed by the movement component itself, the physics engine is never used. Although that seems trivial, it’s an important difference since syncing a PhysX and a ‘Physics’ simulation are two very different things.

The biggest hurdle in this entire system for a true ‘PhysX’ networked simulation, would be syncing the current time frame between all players (hell just one player is nigh on impossible). I tried a few things, even using the windows system clock but over time even that tends to drift. Although PhysX isn’t deterministic, if you can sync the time-stamps then the differences would likely be relatively small (possibly with the exception of collision).

As I said above making a one-size-fits-all physics prediction component is not something you can easily template - I do think however that I’ll clean up my project posted above, and post the source on GitHub so that more than one brain can have a go at it. I’m working from Glenn Fielders example project that he posted - but as I say, his setup is very very different to Unreals’

Hey Jamsh, I would love to be able to take a look at a home rolled prediction system for Unreal as I am pretty sure I would like to try to do something like that.
So I would be very interested if you put your example on github.

With today’s ping times of 20 - 80 ms, you think I can get away with making a game that doesn’t use any lag compensation other than the in-built character movement, and still has vehicles etc. ?

So, there would be input lag for basically everything from firing a gun to steering a vehicle (like in the good olden days…).

But seeing that some of you have spent months to even get started with proper syncing techniques, no hope for “native” UE4 support and no plugin in sight, I am beginning to think that it’s either that or saying goodbye to multiplayer.

I will say the default engine got a bad movement component for networking, you can see the custom components in the Unreal Tournament 4 code, because the default UE4 code when you got 80 of ping or even 60 is unplayable, you can’t even move sometimes.

Not sure why Epic don’t add the code from UT4 or other games of the movement network components as an option.

There are not even an example, you need look into the UT4 code.

What’s the problem with UE4’s character movement? And how is UT different in that regard? I thought, at least that would work well…

And no, I don’t get it either. If they have better solutions, why on earth don’t they put them in the engine? Maybe it would help catching up with Unity, market share wise.

Very nice article and easy to follow. Thanks for sharing.

I will start a project soon, too busy to do so at the moment but I can at least make some headway. The thing is I don’t really know which direction to go with it yet, either do a completely home rolled simulation and NOT use the physics engine, or use the physics engine and try to workaround it as best as possible. Either approach is difficult.

Bear in mind that actually, you actually suffer round-trip time, not just ping - so it’s 20-80ms * 2 by the time you receive the authority RPC’s back. Latency of 30ms or more starts to become quite noticeable for players I’ve found.

UT4 movement code is no different to UE4, it’s just more complex to allow for all the different movement they have (such as dodging / special jumps etc.) - It’s still built on the same Character Movement system, it’s just expanded. Adding all that code to the engine by default starts to make the class even more bulky than it already is, so it’s not a good idea. Most people don’t want that in their game and don’t need the extra processing. The engines Character movement is actually very good. Additionally, the entire point of the prediction system is so that a Character can move on a client without any latency, so no idea why you’re experiencing input lag.

UT4 will eventually have vehicles too. Unfortunately they’re not going to work on it until much later but even so I don’t have high hopes that it will unveil a prediction system for physics objects. In UDK and UT3 - the vehicles didn’t use any prediction at all, they just had hard updates from replication the same way they are done now and that worked well enough for them. vehicles in UDK and UT3 are effectively client authoritative with a ‘bit’ of checking from the Server. Realistically unless your game is focused on vehicles more than characters or bipeds, it’ll probably be good enough for you to use.


Anyway, if you guys want to see what the end goal of my system was, this was it. You can download it and look at the source code, but it’s a vastly different setup and environment to unreal, which is why its so hard to pull off. My eventual aim is to develop a Physics Prediction component that factors in Linear and Angular velocity, and all the end user would have to do is override the functions which calculate the movement and provide a way to send the input to the server as a struct.

The name of the game at this point in time however, is syncing move history. With so many varying factors, that’s the hard part.

http://gafferongames.com/2004/12/28/zen-of-networked-physics/

The UT4 replication works different and is simulated in clients.

It’s not much different, I know because I’ve been looking at it in a lot of detail. If anything they’re quantizing some things or perhaps finding other ways to save bandwidth, but other than that it’s still the same core system.

In other areas of the engine they have reduced some bandwidth usage, but don’t expect anything major.

I am in a very similar position. Did you get a response or figure it out? I understand what I need to build but not sure how to build it. My spaceship control is relatively simple.

I have the matchmaking, objects appearing in game, but only the server’s ship is replicated out, the clients do not see each other move.

What I need is:

  1. Control of local pawn is applied locally (move forward with time step, rotate based on requested direction)
  2. The input controls & transform are sent to the server, along with the timestamp
  3. The server looks at the data coming in, the time that it was applied and applies N frames of control on the server
  4. Server replicates out, to all other clients, the Position, control & timestamp of the extrapolated position of the remote pawn

It could be argued that the server simply replicates out the data it has to all other clients, instead of extrapolation, but this is open to debate and seeing how well it works.

Based on this I am not sure of the layout. The pawn is simple enough, it has a virtual stick which a PlayerController controls. There is also a PlayerState which has the Player’s health,name etc.

So when ticking, if it’s a local pawn, the control is applied.

Questions:

  1. Is time synchronised across all server / clients so we can extrapolate correctly? How do I find time stamp to replicate out?
  2. Do I replicate the transform & controls in the pawn (set to replicate) or do I put them into PlayerState and replicate them that way?
  3. If I set my pawn to replicates, including position, then why don’t other clients see the clients positions update? They are set to replicate so I would assume they would, even if they looked jerky.

Finally. I’m considering through away the custom pawn and using a Character, with a CharacterMovement component. That way this is all done for me, I just need to rejig my pawn to work as a character and I’m done? Maybe that’s a better way of going?

I have something working, sort of, I suspect will look terrible under latency but it’s enough for us to prototype on LAN.

  1. Player state has a control vector in it
  2. Pawn updates itself, gets it’s player state, pulls the control vector (basically a virtual joystick) and drives around based on that
  3. The Player Controller parses the controller input then replicates this to the server (A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums). The server then places it in the Player State which replicates to all clients, when the pawn updates it gets the remote player’s player state and updates based on the control.

I’ve set replicates & replicate movement and things seem to work. Actually relatively smoothly, but not sure what it would look like under real world conditions. I expect I need to put some sort of extrapolation in, possibly adjust the floating pawn movement controller.

Certainly if Epic could release floating pawn movement controller, with extrapolation, it would make building our own custom pawns far easier.

Hi Paul

Sorry on the late response been well out of the UE4 game for a while :slight_smile:

But yeah I just used floating pawn movement components and replicated the movement and it seemed to work out of the box for me in regards to the ships movement…but…like yourself I never tested it in a decent environment other than over a LAN on my home network with just two clients so couldn’t tell you how good or bad it is unfortunately :slight_smile: