Physics, FPS and Multiplayer
I've really be scratching my head at this for days now and i feel iv tried every solution I've found online without any success.
I am creating a physics based game which the player can control a sphere pawn and roll around and do stuff. The way i am moving the pawn is by adding force to it which is a set number, multiplied by the InputAxis, with the function being bound onto the InputPlayerComponent. It is the same setup as the third person template except im using AddForce.
From the information i have found online, AddForce already takes into consideration the DeltaTimeSeconds therefore, you should NOT multiply the force by it, which i am not doing. When testing this in a single player session, everything works expected. 30, 60, or 120 FPS the balls rolls at the same rate. Perfect.
However, When joining a multiplayer session, the ball rolls much faster at higher FPS and much slower at Lower FPS. When multiplying by DeltaSeconds i get the reversed effect. I have enabled SubStepping which doesn't seem to do anything. I have also modified the engine code and implemented a Fixed Timestep which just causes the ball to hop around and still doesn't prevent FPS from dictating the speed.
Is there any solution to this problem?
I can post C++ Code if needed.
asked Aug 30 '18 at 01:55 AM in C++ Programming
I have a suggestion that this happens because SetWorldLocation also affects the velocity, and the way it changes really depends on delta time, thus on fps.Try to pass velocity alongside with location and call SetWorldLocation with 'Teleport' flag (and keep physics enabled on clients, to get more fluid image). Also, I would rather call AddForce in tick, controlled by replicated bool variable that tells if player wants to move. This way I'm sure that my move speed is not affected by network quality.
Here is the demo (done in blueprints, UE 4.20)
Could you please test it and tell if it has those problems.
Follow this question
Once you sign in you will be able to subscribe for any updates here