Skip to main content
GameDev.net gamedev.net
🔒 Locked

physics in game server

Started by sungoco Aug 19, 2010 at 7:43 AM 18 replies 4.5k views
Original Post
sungoco
sungoco
I want to make an mmp with physics but I cannt resolve the c/s synchronous problem. Where I can get help?
hplus0603
hplus0603
The Forum FAQ links to the "Zen of networked character physics" article which is a pretty good starting point.
enum Bool { True, False, FileNotFound };
tomva
tomva
I also have some notes and links collected here: AESOP networking

Even for my hobbyists library, I found I was able to get the Bullet Physics library running authoritatively on the server pretty quickly. And I also have Bullet running on clients, with a thin wrapper on top that tweaks dynamic object positions slightly to account for lag.
sungoco
sungoco
Ths a lot, I'll have a look
sungoco
sungoco
These excellence articles help me a lot.

Where I can get some source code like Quake or some physics MMP?

Quake has opened source?
sungoco
sungoco
Perfect google
sungoco
sungoco
By some testings.
I have my own solution. But I still have some latency problems.
Here is how I drive my physics game:
1.Client:I record character's snapshot every frame to compare with the server result, if the result is not equal to server's result, I fix my character's state;
2.When character is not sleeping(or character is moving), I send character's snapshot and input to server every frame;
3.When server recieved packet of client,server update the character in frame and send the packet (which is recieved by server) to others;
4.Now, I can get perfect synchronization world.
5.But, when character contact with others, I have to fix my character state every time. And my character shakes.

The problem is caused by net latency. When character contact with other at client, It has already happened at server.

How can I do?
hplus0603
hplus0603
This is *the* basic design problem with networked games. You have to pick one options:

1) Introduce enough latency on commands such that the command goes to the server before it takes effect, and then you see the result when it comes back from the server.

2) Accept that clients will be out of sync, and display something that makes sense on the local machine, and fix it up with game rules on the server.
enum Bool { True, False, FileNotFound };
sungoco
sungoco
Ths, but sure , I choose the 2nd option.

Now, It means server runs after client, but when players contact with each other, server runs before client. So when I send my state to server, the state of server is diffrent from client.

So, I guess if the collide happens before server, I can get right result. And I don't need to fix my client.

But how to make the collide happen before server?
hplus0603
hplus0603
Quote:
But how to make the collide happen before server?


You can't do this for sure. If you don't want to delay commands by a round trip, you *have* to accept that there may be corrections to the local player.
You can collide against the forward-extrapolated version of the data receivd from the server, and if the other player hasn't changed velocity/direction in the meanwhile, that predicted collision will be correct.
However, sometimes it will predict wrong, and you have to live with this.
Another option is to only show the player collisions based on what the local player experienced, and tell the server what the local player experienced. This means that player A may think he collided with player B, whereas player B did not think he collided with player A.
enum Bool { True, False, FileNotFound };
sungoco
sungoco
Ths for your suggestion.
But I think "tell the server what the local player experienced" will bring many cheaters.

I'll try correct again.
hplus0603
hplus0603
Quote:
But I think "tell the server what the local player experienced" will bring many cheaters.


You can do the Source/Counter-Strike thing, and rewind time to the point of view of the client, and verify the outcome at that point.
Just watch out for times that jitter too much -- people would turn off their network connection, shoot their enemies, and then turn it on again, to get easier targets.
enum Bool { True, False, FileNotFound };
sungoco
sungoco
Ths a lot.
I'll try your suggestions.
FritzMar
FritzMar
I've been thinking about this for a while to myself, i'm actually planing on trying to pre-bake physics for my multiplayer game i'm planning on having command delay on just about everything but movement if possible on client side i plan on hiding things behind either animation or results. but for physics i'm looking to calculate the path large objects would take and have the client interpolate between its generated physics and the results the server generate until the final result is the same as the servers. and client handles debris generation if needed
0))))))>|FritzMar>
sungoco
sungoco
Quote:
Original post by FritzMar
the client interpolate


How to???
sungoco
sungoco
No answer, May be I need google again.
hplus0603
hplus0603
The Forum FAQ talks specifically about interpolation and extrapolation.
enum Bool { True, False, FileNotFound };
sungoco
sungoco
Ths,I have read many related articles. Now I'm trying TSS.

I have a problem.

As TSS describe.Server should be leading state.And clients should be trailing states. So how leading state rollback??? If server rollback for one client, then the world's state changes. It will affect other clients results.So confuse~~~
sungoco
sungoco
jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter jitter

So many jitters!!!!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.