[Unsolved] Problem w. applying forces over the network (client is faster than server)


I’m currently working on creating a car game that me and my friend can play together. The basic setup that allows players to play over the network has been implemented (Thanks to Epic’s tutorial). We can even drive together on a track. However, there is a slight issue during head-to-head gameplay.

For some odd reason, the client’s car accelerates faster than the server’s. I’ve tried to narrow down the issue by counting the amount of acceleration event calls each player-controlled pawn receives over time on the server. I found that the client’s pawn received more calls than the server’s did. This led me to a potential fix which was that I forgot to multiply the added force by world delta time. I thought this would fix it, but that was apparently not the issue.

Video Example:

I’m dumbfounded and need some help from the community due to still being new at implementing networked-based frameworks. In the following text I will describe how the cars accelerate with relevant figures of the blueprints.

When the player decides to accelerate, their pawn (car) has a force directly added to its physics collider.
If the player is a remote client, the event is replicated to the server (SetAccelerationClient); if the player is the server, the event gets called directly (SetAccelerationServer). Knowing that all player controllers exist on the server, the server-event only executes when the pawn is locally controlled (i.e. is controlled by the server).

Like I said, I’m still relatively new to implementing networked functionality. I understand the concepts, but evidently not well enough.
What do you think the issue is?

(I can provide further information if needed)

I tried another kind of fix.
I tried to apply the acceleration at each server-tick (instead of each client-tick) for every vehicle using the 'Engine Functionality’-event. The only thing that is set with the 'Set Acceleration’-events are now the acceleration input.
The ‘*Engine Functionality’-*event is only run on the server via Switch Has Authority.

However, the results seem to be the same…

While the problem persists I’ve just been trying to work on other minor stuff. Because of this I wanted to run the game directly in the viewport.

The problem also happens here i.e. the car accelerates similarly to the client even though it is controlled by the host.
This is NOT the case when running a standalone version of the game.

Is there a problem within the Blueprint(s) that make the acceleration behave differently depending on a potential null-instantiated variable?

Sounds to me like a classic network replication issue.
The server should be handling the acceleration for the clients in order to allow exact measures for both clients.
seems like you have it set that way by what you wrote…

In reality, there is no exact fix for this.

On the client you are running one simulation.
On the server another.

The server drives the client, so in the event of a desync the server tells the client to reset to the position he has.
thus, lag, stutter, etc…

Usually, you go around this by having the client drive the server, and having the server drive additional clients.
this is still prone to lag. However.
A client driving who has a high ping is still somewhat accurate since he’s driving the changes you propagate to other players.

Perhaps less obviously, allowing a client to drive the server is an immediate cheat. You can hack your way into changing the location of the player, and the server just has to take it as gospel. Thus, you make it (somewhat) easy to cheat (Hi there Rockstar!)
The player experience is obviously better.

The default plugin’s Net Code could probably be updated for your specific use case, so that acceleration is handled faster/at higher ping rates, etc. But you basically need to be a videogame network engineer with 3 years of work on the subject to improve what is there.

you can hope that the new changes brought about by Chaos will provide you (eventually) with a better solver and a better network code. Since for the most part Fortnite doesn’t have glaring issues except for some specific server.

That said, perhaps someone more versed on both network and car racing can give you a better fix.

Also, maybe its possible to scale by the client ping in some way. Meaning: The server drives everything, but adjusts what is what for the clients based on the local ping.
make everyone automatically lag as much as the lowest connected ping.
NOT optimal, for sure, if not just a stupid idea…

Hi MostHost LA,

Thanks for the reply.

When you say that acceleration should be

do you mean that the difference in event call amount between the server and client actually is the issue; that the forces added to the client’s vehicle should be scaled down depending on ping? Because I can see how that might be the problem.

Therefore, I have tried to remedy the issue by not applying the forces inside the server-replicated event but instead apply them at every server tick. This way, the frequency of applied forces should be the same for the server and the client regardless of the client’s ping. However, like I state in my *edit *above, this did nothing to fix the issue at hand.

I can not think of any other fix to this problem right now. The only other thing I can think of that might be the issue is if there are two server-authoritative programs running at once which would result in the client accelerating twice as fast. But I feel like that is not at all the case. There must be something we’re missing here.

Likely, I know theory more then practice on this subject.

And yes, I suspect the difference in call amount is due to network lag.
Hopefully some of the guys with more Unreal experience on the subject will chime in. Keep bumping :wink:

Bump. See post above…

Bumping for ya. May want to consider asking in the blueprint section.