Jump to content
  • Advertisement
Sign in to follow this  
pacogmont

physics in a multi-player app

This topic is 4565 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, First, sorry about my English... I need some advice about how to distribute physics in a multi-player app. I have two scenes in theory: 1. - All Physics stuff, collisions, logic game running in one machine and update this info to every client connected. Thus, clients must send to the server its user inputs. Pros: - More simple architecture and implementation. Cons: - Heavy CPU Load in server if there are a lot of physics entities. 2. - Share Physics in each machine. I mean, every client control its own entities locally and share its 3D info to the rest. Pros: - Share CPU Load in every client machine Cons: - Difficult to implement because there is a physics engine running in every client

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Keep in mind that for networked games, there really is no need to keep all the physics driven entities in sync across multiple clients: when a player A dies and his sword goes flying, player B and C will see it flying away but really won't care if it doesn't fly away in the same direction and with the same arc on both clients. So what you would do (for example), is just send the entity's initial location, velocity, and whatever forces are acting on it to the client, and have the client calculate the physics for that entity on its own.

Ofcourse it might be important to keep the physics of certain objecs synced across clients because they are important to the game, but such objects should be few in number and special case handling can easily be added to have the physics calculated on the server and then pushed to the clients.

Share this post


Link to post
Share on other sites
Hmm, I'm a noob around here but I play a lot of online games.

So, your first method is more like Counter strike right?

I recognize your second method with a Gunzonline like system. Though it's a fun game, there's a lot of complaint since if there is lag, a person would only see an enemy's state from 5 seconds ago or more.

Your second method would work fine if the connection isn't an issue. This is from the perspective of a player and not a coder.

Share this post


Link to post
Share on other sites
I would think the best way to do it would be to send as little data as possible across the network. Why not just send the bare minimum (the position,velocity,weight of the object) and let each client calculate it themselves. Since they are running the same game, wouldn't the resulting animation be the same regardless of where the information is being calculated? I think that is what you are recomending in your second approach, but I am not sure.

Share this post


Link to post
Share on other sites
If you have real physics, where objects can block you from moving, and flying swords can cut your head off if they hit you, then making sure that everybody see the same thing is important.

If you let each machine calculate their own physics, then you may open yourself up for cheating hacks where someone changes the local calculation and gets an advantage on the other players.

Share this post


Link to post
Share on other sites
Well thanks, there are many interesting answers!
I have to clarify that my app is not a game it’s a simulator in fact, so I have no problem with cheating :)
In my environment distribution is a must. We avoid of making the simulation runs in a mainframe.
I’m thinking in one solution; let me know what you think of it.
Each client has a physics engine and owns some entities.
One of the clients is a car and its physics are calculated in the local PC, but if the car is going to hit with a barrel that has its physic representation in other client –they are close enough-, I could make an ownership exchange. The barrel physics is now in the car client and could interact with the car. Or in the other hand I could send the car and the barrel to the server…

Share this post


Link to post
Share on other sites
If you want authoritative peers where each peer has ownership of certain entities, I suggest you google the architecture of DIS (Distributed Interactive Simulation), also known as IEEE standard 1278. The simulation people solved that kind of architecture 15 years ago, and there are many current simulators that interoperate using this standard.

The DIS standard (which is a wire protocol standard) then grew into the HLA (High-Level Architecture) standard, which defines an API but not a wire protocol. However, because of some choices in the HLA design, it's not as interoperable as DIS and thus might have less broad production adoption in the simulation industry.

Share this post


Link to post
Share on other sites
OK, thanks!

One last question:

Witch is a better approach?

1.- The client send to the server that forward button has been pressed, and then the server tells the client (and the rest of the clients) how much he has moved.
Or
2.-The client moves forward and tells everyone where is he now.

Share this post


Link to post
Share on other sites
Never mind,
I’ve already found the solution to my question here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=388048

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!