Wednesday, August 26, 2009 at 9:42 PM |  
After countless hours of sleepless nights, I finally got it going! Smoothed network physics simulation will little noticeable jerks. Yay! However, this is only for the LAN. I'm not sure how it will fare with the internet where latency isn't our best friend.

It took me a while to figure out that I had to synchronize the physics time frame and not the system time frame. Top that off with bad timing for the network syncing right after physics simulation was done, I was having a lot of headache beating around the bush for naught! Sheesh...

Aside from this, I'm having issues with float compression. Somehow it's giving weird values that leaps all over. Probably something wrong with the way I compress and decompress. While on this, I wonder if I should have some way to mark significant objects for non compression mode? How does other games normally does it anyways? Do they like make important objects like controlling player to always sent in non compressed mode while other non controlling objects get compressed mode?
Posted by Lf3T-Hn4D

11 comments:

Yakov said...

I restoring my networking same time. How do you do networking? client - server - snapshots etc? i am compress using delta snapshots (only changed objects and data members are sended) plus bit compressing, and thinking about Hoffman compression.

August 27, 2009 at 12:25 AM  
Lf3T-Hn4D said...

Yep, I'm doing it the client-server way. Client request for snapshot, server replies with snapshot. Base on client's camera, server finds all relevant entities and send in snapshot. Entities that was relevant for the past 5 seconds is also included even if it is out of the camera's view bound.

As for compression, I'm only doing delta compression for objects that doesn't require frequent updates. For positioning, I'm basically doing offset positioning with camera as the origin. That way, I was hoping that I could compress the float values to 22bits. But looks like it's not working right. I need to look more into my truncation code of IEEE floats.

Does Huffman compression work well for arbitrary binary data? I thought it was rather waste of cpu just to do that. Though it might be a nice thing to do for text(assuming everybody uses english).

August 27, 2009 at 12:53 AM  
Yakov said...

i want to implement also client-side prediction. Calculate player movement on client, and confirm from server with smoothly moving from client camera position to server camera position. And

Are you using UDP?

August 27, 2009 at 1:27 AM  
Lf3T-Hn4D said...

Yes, do that. Client side prediction is very important. Always simulate what the server is simulating. That way, we won't snap as much when server sends correction. :) Just make sure that after every snapshot sent from server, client must move back to it's current position by simulating from snapshot time to current time. (Since snapshot is always older than current time. Unless your client is lagging.) To smooth things out, what you do is record the old position before snapshot and interpolate with the position after the re-simulation. (meaning after applying snapshot and simulating to current time) Have a look at Glenn's awesome article on this. http://gafferongames.com/game-physics/networked-physics/ Though it's outdated and he's using other methods now, it's still very applicable. This is especially true if we want to have deterministic simulation where we can save replays.

Yes, I'm using UDP. Infact, I'm using enet as my network layer. It's very easy to integrate and takes care of connection and packet deliveries that imitates TCP when I need them. You should look into that. :) http://enet.bespin.org/

August 27, 2009 at 1:56 AM  
Yakov said...

thanks for link, but i already implemented it with sockets. about simulating all physics on client - i am not sure about it. I have interpolation between snapshots for all objects with time correction, looks like it's enough.
btw, how do you debug networking? i broke my head already ) launching server, client, one more client, asking friends to launch server.. do you have some tool for simulating slow network?

August 27, 2009 at 2:46 AM  
Lf3T-Hn4D said...

Ah ok. :) Good for you then. I personally feel client side physics simulation is good in cases where say consecutively a few snapshots are missing due to lost packets. If you just use interpolation, things would look awkward in that case.

Network debugging is a headache. I personally haven't really gone further than just LAN at the moment. I have two working computer to test things out. One faster than the other. So it kind of helps to test both cases of when server is faster than client or client is faster than server. As for slow network simulation, you could try the QoSEmulator by author of RakNet. Though I don't quite like how it hijacks all my apps that uses the network. Very annoying. I personally thinks the best way is to actually try it out with a friend over the internet. ;)

August 27, 2009 at 3:33 AM  
Yakov said...

http://www.jenkinssoftware.com/
what do you think about this free (for indies) network library? a lot of work done, lobies, friends list etc

August 31, 2009 at 11:42 PM  
Lf3T-Hn4D said...

Yes, that's nice. I've looked into it many times. It's quite feature complete including support for NAT punch through. Though it's not really free for indies. If you intend to sell your software that uses this library, you will need to pay for it.

For my case, since I've already designed my own object propagation system around enet, I felt that I don't need this. But if you are to start from scratch, I think it's a good engine to use. :)

September 1, 2009 at 12:44 AM  
Yakov said...

if you have revenue less then 250 000, you need not to pay. I asked my friend, he used it 2 years. He decided to move to boost asio.

btw did you think about voice chat?

September 1, 2009 at 12:49 AM  
Lf3T-Hn4D said...

Oh. I supposed it's quite limited in the way you do things. Yes, I did thought about voice chat. However, that requires VoIP features. I've thought about using speex as the compression technique. But never really delved deep into it yet though. I still need to get sound system up first. :)

September 1, 2009 at 1:28 AM  
Yakov said...

http://gafferongames.com/game-physics/networked-physics/ - after day of thinking about client side prediction and correction from server, found your link very usefull )) thanks

September 1, 2009 at 3:38 AM  

Post a Comment

Liquid Rock Games and Project Aftershock. All Rights Reserved.