Download

Multiplayer - why client is moving slower than serwer?

I’ve an endless game where you are flying through the hole. Here’s my specs:

  • Pawn’s Movement Component Max Fly Speed is taken from server - because the game is making faster in time,
  • Using Tick I’m adding Forward Movement using Add Movement Input - so the players is moving forward but can’t move faster than Max Fly Speed,

When I play in multiplayer client is moving slight slower than server and I don’t know why because:

  • Velocity is the same on both, (tested using HUD)
  • Max Fly Speed is the same on both, (as above)

When I play as a server and I’m near client I can see he is glitching…it looks like he is getting impulses to opposite directions than movement. But velocity and max movement arent changing!

Anyone with replication knowledge can help me out? If more information needed please let me know!

Are you replicating movement?

Also, also, his position will be limited by the server, who has ultimate authority. The problem may be inadequate movement prediction - the player is moving so fast and the server can’t handle that many updates or it can’t properly predict the next position (though it could with modified prediction code). I don’t know how to do either of these things at the moment really, but my solution for a similar problem was to have the world move around the players. The world moves at a constant rate, and the players move at a rate relative to that that would appear to be Max Speed. That way, they’re actually moving very little, and it’s easy enough for the server and other clients to predict their location.

Thanks for reply Cobryis!

Yes, I’m replicating movement.

Your solution sounds good but I can’t move world (game is on mobile). So basically UE4 can’t be used for high speed racing games in multiplayer? I don’t think so because there are lot’s of MMORPGs done using UE3 which have lot more informations to be replicated.

I think that I’m doing something wrong here and there is an solution. My pawns have Max Fly speed around 2000-3000 max this isn’t that much. Max Fly speed is increasing by server and replicated to all pawns.

I will dig more.

You can move the world. I’m not asking you to actually move the map around the player, but all the parts of the relevant actors in the world could potentially be connected to some position or some actor that’s moving. The problem with high speed movement is that there is no good solution for seemingly unpredictable high speed movement. Car games or flight games use dead reckoning and other techniques in order to produce an illusion of replicated movement, but these games are also notoriously dependent on a solid internet connection (or else you get what’s called rubber-banding). In a more linear game (which yours sounds to be), the easiest and maybe best solution is to move the world (taking care of the “fast” part on the clients’ sides) and then use the built in replication for players relative speeds.

However, if that’s really not an option and you need something more like the replication of a flight-based game (where the players can fly in any direction), see how the UE4 vehicle demos hold up in multiplayer (if at all). Maybe modify their speeds and put the vehicles on a flat plane. Also look into the MovementComponent API to see if there’s options available to improve high speed movement replication (if so, the vehicles are likely taking advantage of those).

Yes I know, but in mobile I won’t have lighting then. I’ve proceduraly generated maps using streaming and instances - static lighting is working on mobile. So yea… I can’t move the world :frowning:

But even If I can it will be moved with the same speed as player so there will be more data to be replicated. I can’t make my map smaller because gameplay is about collisions and small collision in UE4 = bugs later on.

Thanks for your link and theory, will check them out. I will dig into MovementComponent as well. Will let know here how I fix the issue.

Oh okay, I suppose I don’t know how lighting works on mobile. I’d imagine there has to be some way to bake lighting into objects so they can at least look shaded. As for casting shadows on moving objects, I’d have no idea what to do.

Go for whatever is simplest! Good luck.

I’ve found an issue. Max Fly Speed isn’t working on client. If I’ve Max Fly Speed set to 1 from game state server will slow down but client will not.

I’ve added AH bug here: [bug]Max Fly Speed replication bug? - UE4 AnswerHub

So basically even if I have Max Fly speed set to 1 in defaults I can see that server is moving faster than client :slight_smile: What I’m doing wrong?

Another thing is when I change velocity or character movement variables in tick - even in Third Person Template replication movement is breaking. (for example: in my server I can see that other player is moving and in client I’m standing still).

Maybe Epic can tell us what’s the best way for changing speed in multiplayer because I think that using Tick isn’t working correctly.

EDIT:
If I set default Max Speed to 3000 and add movement input in tick - everything works correctly. When I change velocity or something in movement component it’s starting break.

SOLVED: Character Movement max walk speed replication ? - UE4 AnswerHub