Tuesday, June 29, 2010

Networking Improvements

After reading through the code of the network prediction project provided on the XNA Creator's Club web site, I was able to implement the prediction and smoothing algorithms into our game. Although it didn't completely remove all the stuttering, I'm happy to say it did help a great deal. This worked fine for regular characters, however, I was faced with a bigger challenge of fitting these algorithms into the Tank class which uses Farseer physics. After thinking about it a bunch, I decided to forgo the algorithms for the Tank class and take another look at ways I can improve its stuttering. I studied the data I was sending for the tanks and discovered I had omitted a very important piece of data.. the velocity! The reason I made this mistake is because I use a Vector2 called "Trajectory" for the Character class which is the velocity. But the Tank class, which is derived from the Character class, uses the Trajectory variable to store the force that is applied to the physics object. The velocity itself is kept by the Farseer class "Body". So I added this data to be transmitted over the network for syncing. Through the testing I've done so far, this works well. However, there could be issues I might see only after some real play testing.

Besides the code updates, we also finally decided to pay attention to another critical aspect of the game.. the design. I downloaded a game design doc template and we started going through it, answering a lot of important questions about what we want the game to be like. I can see a lot of time will be spent on this doc, considering we spent an hour working on it and only got about 25% through it. Good times!

No comments:

Post a Comment