Hi,
CONTEXT
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.
THE PROBLEM
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: http://youtu.be/Uzh1rkCVAEY
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.
INFORMATION
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)
EDIT:
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…