Chipmunk and networking
-
- Posts: 8
- Joined: Tue Jan 01, 2008 5:24 pm
- Contact:
Chipmunk and networking
Hi, I'm planning a 2D top down vehicle shooter, and I'd like to include multiplayer support, using networking, over LAN (low latency, less worrying about bandwidth).
My question is if it's possible to use chipmunk as the physics library for this project, and I'm asking because from what I've seen, sometimes, the simulation is not always the same on my computer, when running the demos. Could this cause any problems with the game, like, one person sees one thing, and another sees another, just because of chipmunk?
Any troubles that may arrise from this unequal simulation? How should I handle this?
My question is if it's possible to use chipmunk as the physics library for this project, and I'm asking because from what I've seen, sometimes, the simulation is not always the same on my computer, when running the demos. Could this cause any problems with the game, like, one person sees one thing, and another sees another, just because of chipmunk?
Any troubles that may arrise from this unequal simulation? How should I handle this?
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Chipmunk and networking
You are correct, given a different processor or compiler, the physics won't run exactly the same due to floating point errors. When writing your networking code you are going to have to keep that in mind.
I've never really written a complicated networking game, so I don't really have any experience to draw on. If I was implementing such a thing, I'd be continually sending out snapshots of the objects. If there's only a few objects, you could probably just send out a full snapshot on every packet. If you have a lot of objects, send out a few of the objects at a time.
On the other hand if you are assuming low latency, maybe only run the physics server side. The clients then just display objects using the last know positions and dead reckoning. Would certainly make writing the client code easier.
I've never really written a complicated networking game, so I don't really have any experience to draw on. If I was implementing such a thing, I'd be continually sending out snapshots of the objects. If there's only a few objects, you could probably just send out a full snapshot on every packet. If you have a lot of objects, send out a few of the objects at a time.
On the other hand if you are assuming low latency, maybe only run the physics server side. The clients then just display objects using the last know positions and dead reckoning. Would certainly make writing the client code easier.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 8
- Joined: Tue Jan 01, 2008 5:24 pm
- Contact:
Re: Chipmunk and networking
Thank you very much for your help, that gave me some nice new ideas to have in mind.
To clarify, I don't plan to use multiple compilers, since I'm using only Delphi, so you can assume that all the versions running will be exactly the same. But the processors, no way.
Onto the new questions
Does anyone knows how can I handle this floating point errors on the application?
If I send snapshots of objects, what would they contain? Forces? Heading? Can I set it directly in chipmunk, or should I do something like this:
Given the client's current position
And the desired position received from the server, do:
Calculate force so that current position becomes desired position. Apply.
Something like this?
I could also only send the snapshots that are "in range" of the client (like, distance less than 30 units), an easy optimization to reduce the snapshots.
I'm also considering doing the physics server side, I'm not sure however about the responsiveness client-side, that's something I should experiment to see it working. However, I'm not sure about the dead reckoning (heh, never did something like this, either).
Thank you for your help, and pleased to hear any other idea on this subject.
To clarify, I don't plan to use multiple compilers, since I'm using only Delphi, so you can assume that all the versions running will be exactly the same. But the processors, no way.
Onto the new questions
Does anyone knows how can I handle this floating point errors on the application?
If I send snapshots of objects, what would they contain? Forces? Heading? Can I set it directly in chipmunk, or should I do something like this:
Given the client's current position
And the desired position received from the server, do:
Calculate force so that current position becomes desired position. Apply.
Something like this?
I could also only send the snapshots that are "in range" of the client (like, distance less than 30 units), an easy optimization to reduce the snapshots.
I'm also considering doing the physics server side, I'm not sure however about the responsiveness client-side, that's something I should experiment to see it working. However, I'm not sure about the dead reckoning (heh, never did something like this, either).
Thank you for your help, and pleased to hear any other idea on this subject.
-
- Posts: 8
- Joined: Tue Jan 01, 2008 5:24 pm
- Contact:
Re: Chipmunk and networking
I also have another question:
Is chipmunk deterministic, or non-deterministic?
From what I've googled, deterministic physics engines should be ideal for networked games.
Is chipmunk deterministic, or non-deterministic?
From what I've googled, deterministic physics engines should be ideal for networked games.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Chipmunk and networking
Chipmunk is deterministic, but not in a simple way. As long as collisions are processed in the same order, the simulation will be deterministic. Collisions are considered in the order that they are reported by iterating a hash. The hashing order is determined by shapeIDs (created specifically to deal with the determinism issue). Again, a different processor or compiler will also generate different floating point code that will produces slightly different simulations after many complex interactions.
The documentation for cpResetShapeIdCounter() is a bit vague, but you should start there. What's not clear in the documentation is that the shapeID counter is global, so you can't really be adding shapes to more than one space at a time.
The documentation for cpResetShapeIdCounter() is a bit vague, but you should start there. What's not clear in the documentation is that the shapeID counter is global, so you can't really be adding shapes to more than one space at a time.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 8
- Joined: Tue Jan 01, 2008 5:24 pm
- Contact:
Re: Chipmunk and networking
Ok, thank you.
I'll try to make a client/server simulation, and see if it works. Otherwise, I'll go for the server only simulation.
I'll try to make a client/server simulation, and see if it works. Otherwise, I'll go for the server only simulation.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Chipmunk and networking
I had bookmarked a couple of good articles on the Quake 3 and Unreal networking models a while back. I'll see if I can dig up the links when I get home.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 8
- Joined: Tue Jan 01, 2008 5:24 pm
- Contact:
Re: Chipmunk and networking
Ok, thanks.
Meanwhile, I've been googling, and I've found this very interesting topic on the subject:
http://www.box2d.org/forum/viewtopic.ph ... &sk=t&sd=a
It's a good read, plus, follow the links there.
Meanwhile, I've been googling, and I've found this very interesting topic on the subject:
http://www.box2d.org/forum/viewtopic.ph ... &sk=t&sd=a
It's a good read, plus, follow the links there.
-
- Posts: 56
- Joined: Tue Sep 11, 2007 2:30 pm
- Contact:
Re: Chipmunk and networking
Maybe you mean the ones linked to in the sticky post in the networking section on the idevgames forum?slembcke wrote:I had bookmarked a couple of good articles on the Quake 3 and Unreal networking models a while back. I'll see if I can dig up the links when I get home.
http://www.idevgames.com/forum/showthread.php?t=13402
Those three pages are definitely very interesting.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Chipmunk and networking
Why yes in fact. I got them out of the iDevGames irc at some point. I had forgotten that they were on the forums.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 34 guests