Hey There,
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.
I’m pretty much sure that AddForce is not the cause of your problem. How did you setup your replication?
Hey,
I have all the movement functions running on the server side. Physics is also enabled on the server side only and disabled for the clients. In the Tick Function i then have a custom function which sets the clients transform to whatever the server has calculated it should be.
Edit: After this comment i went and disabled the tick function and enabled replication on the sphere mesh and the same issue still applies. I tested a little bit more and im pretty certain its how many times the client is calling the move functions. Since i have the move function bound to the PlayerInputComponent, its getting called more often at higher frame rates. Meaning the amount of times AddForce is being called at higher fps is crazy high. I’m not sure if i can limit this though.
Edit 2: I also forgot to mention that this issue only applies to the clients. The listen servers physics still function correctly regardless of the FPS.
Edit 3: The issue only seems to happen on Standalone version of the game. Using PIE seems to have expected results.
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.
Hey there!
Thanks for setting this project up for me its actually super helpful. After tested it the same way i did with mine, Yours seem to work flawlessly.
Its really late at the time of posting this but i wanted to just give you a quick update.
Tomorrow, I’ll go back and re haul my c++ project to see if i can get it working using the same approach you have. I’ve probably littered my code through countless changes and made it worse and worse overtime.
Side note: I noticed you used a player controller, something i completely overlooked as i did all the movement within the pawn. Maybe this has an effect?
Using player controller is more of consistency thing. There could be numerous reasons, why it worked like that. This could be dropped network packets, or misuse of ‘SetWorldLocation’.
P.S. don’t forget to mark this as answered
Re created your setup on my own project in blueprints and once again worked flawlessly. There was a little bit of jitter on the client side when playing online but i managed to fix that by using a little bit of interpolation.
Can’t thank you enough for solving this. Thanks again for sending over the project and helping me out <3