tonihele / OpenKeeper

Dungeon Keeper II remake
GNU General Public License v3.0
428 stars 41 forks source link

Implement movement prediction #425

Open tonihele opened 1 year ago

tonihele commented 1 year ago

Implement movement prediction. Currently our steering and animation systems run on a separate thread with very high intervals for smooth movement. It is very heavy and poses some challenges on multithreading. We are quite ok with multithreading, but not 100% secure.

The biggest thing is perhaps is that this is not the correct way of doing things. Especially looking at multiplayer aspect. And creature possession.

I propose the following:

This should be fairly straight forward to implement. The only thing I'm kinda thinking is that somehow we would need to probably know on the client side, that what object is static and what is not. There are many objects on the map and only some are really moving. I'm not entirely sure at this point that is this going to be an issue or not.

And another thing is our steering. It is a bit wonky... So how easy it is to linearly interpolate / predict? I mean it should be... right? But might need so adjustments to the steering itself which has proven to be quite challenging...

tonihele commented 2 weeks ago

Biggest challenge is definitely the steering. How to not make it offshoot the target and not go trough walls. See https://github.com/tonihele/OpenKeeper/issues/430. It doesn't matter how often or seldom we calculate the streering. It should be more predictable.

The dungeon heart animation can probably go to just view only. For server it doesn't do anything. All effects are perhaps client only. The plug pieces just need decay in the server, or that they are even never added by the server in the first place?

For the client side interpolation I use this as a reference: https://github.com/Simsilica/Examples/blob/master/sim-eth-es/src/main/java/example/view/ModelViewState.java

With all of these and then enqueuing the client requests to the game loop, we can totally get rid of the locks and everything is pretty predictable. Also the step should be made fixed.