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 ...

Get Beginning 3D Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.