Client-side prediction?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Client-side prediction?

Postby Lynix » Sun Dec 17, 2017 7:53 pm

Hi there,

I'm using Newton Game Dynamics for my networked game, which does State Synchronization to synchronize server/client simulations (which basically calls NewtonBodySetMatrix/NewtonBodySetLinearVelocity/NewtonBodySetAngularVelocity on the client on a regular basis).

To provide lag-proof inputs, I implemented client-side prediction earlier (before integrating physics) which was working quite well; it worked like this:

1) Player presses a key; generate an input
2) This input is applied to the controlled entity and stored in a "pending inputs" vector
3) Input is sent to server with an incremented ID
4) When the server sends an entity snapshots, it includes the last input id it processed
5) Client receive snapshot,apply snapshot position/rotation to predicted entity, remove processed inputs and apply every input which has not yet been processed by the server

It was fine until I had to put physics in there, now I'm using state synchronization and I'm stuck on how I should implement it, especially how to reconciliate client and server (step 5), how can I simulate only one body in Newton without simulating the others?

Thanks in advance
Lynix
 
Posts: 2
Joined: Fri Dec 01, 2017 12:24 pm

Re: Client-side prediction?

Postby JoeJ » Mon Dec 18, 2017 3:36 pm

I know nothing about this, but there are some things to try:

I think there are functions to integrate a body, so no forces but at least something to get visual results for very short periods of time.

You could create temporary world, copy object of interest and nearby enviroment, eventually make the enviroment (or parts of it) static bodies and simulate just that. That way you could even simulate a ragdoll with a good chance to match results.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Client-side prediction?

Postby Lynix » Mon Dec 18, 2017 7:29 pm

Which function are you talking about exactly?

About the temporary world, well this is my backup plan: synchronize every server entity position/rotation on a secondary world where they have no mass and don't move, and just allow player entity to move by running a step for every input, but I'm wondering whether it's efficent or not.
Lynix
 
Posts: 2
Joined: Fri Dec 01, 2017 12:24 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 16 guests