Using Ogrenewt + Network

hoffhoff

27-11-2007 01:11:48

Hello,
Well, my question is not directly related to ogrenewt, but I think that this is a good place to open this discussion. If not, I am sorry for this thread then.

I am building a game using Ogre+Ogrenewt+Newton, and I want to implement the newtorking part now.

Has someone here ever created a networking game using ogrenewt?

I am still planning it, but I am not sure of what is the best way for making it.

I was wondering about implementing all the physics stuff in the server. So, the clients would send to the server the pressed keys, and the server would interpret it (just like in the singleplayer mode). Then, every period of time, the server would send to the clients the position and orientation of all the objects in the scene. So, the clients would not have any physics implementation at all: they would be just rendering the screen and updating the position of the objects to the positions received from the server.

Is it a good aproach?

Another solution I thought: the clients would send only the pressed keys, and the server would broadcast it to all other clients. Then each server would calculate, in it's own world, the affects of that key.
So, if one press "ahead" button, all the clients would apply a force to move that player ahead.
I think that this solution would economize network band, because the messages sent between client and server would be smaller, but I think that lost packages would mess the synchronization of the clients.

Have someone worked on network games?

And again, sorry if this is not the right place to ask this.

Thank you

chriss

27-11-2007 11:19:40

Well i neverd did it but i also want to try it.

Your last option is the one you should never use. Because of the time difference the simulations woun't be synchronus.

Your first idear is better because you have allways synchronus simulations. But here you will see all objects jumping from one point to another.

A good solution would be a mix of both ideas. Send all actions to the server wich runs the main simulation. The Server then sends the action with the actual position to the clients.
The clients run their own simulation and interprete the actions. As addition they check if there is a big differenc between the position of the object in the local and the server simulation. If it is so the client can set the object to the server position.


Thats what i want to try but at the moment i have no idea if it's possible te break the simulation reset the objects and continue the simulation.


Greets Chriss

Tubez

27-11-2007 16:00:33

You also need some sort of lag compensation. There are many techniques, have a look around.

hoffhoff

28-11-2007 21:13:20

I´ve found this link, and it explains a little about FPS games online:
http://www.gaffer.org/game-physics/networked-physics/

I will try to develop something similar this week, and then I´ll post here the results =]

C ya

Tubez

28-11-2007 22:47:44

Good luck man!

sharkyx

29-11-2007 09:53:52

Here is some example code and explanation with Newton and Zoidcom as network layer.

http://www.zoidcom.com/wiki/doku.php/newtonzoidcom

hoffhoff

01-12-2007 12:57:01

Thanks for the link sharkyx.
Are you a developer of zoidcom?

Creating multiplayer games seems harder than I thought :shock:

But it seems that most of that calculation is to prevent hack, right?

Do you think that my first idea (the client sends the pressed keys, the server recalculates it´s position and then update the clients) would work if we could trust in the players?

I am a little worried about the bandwidth.
I started working on it, but I don´t have another comuter to keep the tests =/

If someone wants to help me, I´d appreciate a lot =D

sharkyx

01-12-2007 13:45:17

Yes it works. That's what the article is about. The problem is staying in sync when just sending keypresses. Updating the other clients with stateupdates is a lot easier than maintaining sync between the player's movement actions and the server. At least when you do client side prediction.