HateDread
(HateDread)
July 18, 2014, 6:29am
4
What you’re trying to do (simulating client movement locally AND on the server) is called client prediction, and I’ve been trying to get it working with the UE physics for a while.
The hard part is letting the client trust the server and fix their own simulation with the server’s, as that will be in the past in the client’s perspective and snap / jitter like you explained in your first post.
The common way to do it is remember and store all the movement and input that happens with timestamps, then when you receive and update from the server (with client timestamp), snap to the received state, reapply all movement and input since that time and delete all locally stored information before that state.
I gave up for a while as I couldn’t find a way to force an actor to simulate physics to reapply the movement, but if Super::Tick does what I think it does I might have to give it another shot…
Some relevant AH posts of mine…:
Client prediction & reconciliation theory for physics based movement - World Creation - Epic Developer Community Forums
Simulate a certain time period of physics for an actor without actually progressing time - Character & Animation - Epic Developer Community Forums
I’m not sure how effective your lerping solution is - I thought of doing that too initially, but the simulation the client runs would still be in the past compared to the player’s input, blended with the client not acknowledging server’s simulation at all. (Since that’s what a lerp is) You may want to draw a debug point on the position that the client receives from the server before you interp to it, so that you can compare them, and then test it out on a high latency connection, maybe fire some impulses on the server or client to try and desync them. An effective method will acknowledge the server’s simulation but still feel responsive to the player as if he/she were playing on the server itself.
If you’re happy to trust your players not to cheat, you could use Rama’s method of letting the clients send their location to the server, and the server trusting that, however I can’t give so much trust to my players and would rather a full authoritative approach like the rewind-replay method
[Video] Player-Controlled Replicating Physics Movement, Simulating Physics! - C++ - Epic Developer Community Forums !
Hey Acren,
So the part that’s frustrating me at the moment is actually figuring out how to run the local simulation, as you mentioned, and be able to manually invoke the replicated version. If I use the ‘Replicate Movement’ box, the location data in the Actor/Pawn is automatically overwritten, no? I then lose any track of my ‘previous’ location / local physics location. I feel paralyzed by a lack of documentation of how all of this actually occurs .