O'Reilly logo

Beginning 3D Game Programming by Tom Miller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending and Receiving Data

When it comes right down to it, a network session is a way for the various players within the session to transfer data to one another. That is the heart of a network game. So what you need to do first is figure out the way to send some data to another player. Look at the method in Listing 16.9 for the implementation of sending the player's location and orientation to the other peer member.

Listing 16.9. Sending Position and Orientation
 /// <summary> /// Will send the player's position and orientation to the other peer /// </summary> public bool SendPlayerLocation(Vector3 position, float rotation) { // Check to see if we can send this message if (CanSendData()) { // Create a new network packet to send the player location ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required