The LOD Game

The LOD Game

With uStream we have provided a demo game to learn and test uStream together with Unity. The unity project can be downloaded from http://download.muchdifferent.com/ustream/TheLodGameUnityProj.zip
LOD is an abbreviation for “Level of Detail”. LOD is the same concept as “Area of Interest” in this product manual.
The game includes a simple server scene and a simple client scene. It can be tested with arbitrary number of NPC objects (configurable in the script server.cs) and as many players (clients) as you want.
The game is just 2D, but all calculations in uStream and all calculations in the LODgame is based on positions in 3D.
The line of sight radius is 20. This is a configurable public property of the script CubeProxy.cs attached to the CubeProxy prefab in the Resources folder. If you alter this value it is nice to change the scale of the “Visibility Area” game object located in the client scene just to make it reflect the actual line of sight.
The radius for the area of interest is 30. This is configured in the ustream.config file for uStream. The following image shows the demo game server. All the small cubes are NPCs moving around the small and flat world.
images/LOD-game-screen.png

The following image shows the demo game client. The green circle marks the Line of Sight for the player.
images/LOD-game-client-screen.png

The motivation for keeping the line of sight a bit smaller than the visibility area is because when the player moves, they will start to see some new objects just outside the line of sight since the visibility area moves at the same time as the player. Then it is important for the client to have some information about objects just outside the line of sight in advance.
There is a value in uStream for configuring how often it should calculate what objects are inside a player’s area of interest. The default value is 250 ms between calculations. Make sure the player can’t move too fast compared to this value. A player should never be able to move during the 250 ms resulting in a situation when the line of sight will is “outside” of the area of interest. This would result in a situation when objects can appear (pop into existence) inside the players line of sight. But the player is not the only moving object to consider.
If another game object can move faster than the player, the area of interest will have to be bigger or the AOI recalculation interval will have to be smaller, or both. Make sure to test well that the fastest moving objects in the game can not appear inside a player’s line of sight. All objects should appear exactly at the border of a player’s line of sight.

Running the LOD Game

Make a stand-alone build for the server scene. This way you will have an exe file to start the game server.
Start uStream and the game server.
Run the client scene in the Unity editor. It will connect to uStream’s default port 4001.
The client scene in the demo game shows other players and NPCs inside the LOS. The LOS is marked with a circle that follows the player’s movements. It also shows objects outside the LOS as cubes with another color (white). This is only to make it easier to understand how uStream actually works. In a real game the objects outside the LOS should be invisible.
Please try moving a player around and look at the area in front of the player. Look at how the white cudes appear just before the cubes enter the green visible area. This is exactly how it should work.
Use the TAB key to enable (or disable) the “uLink statistics GUI” (it is a uLink utility script) in the client and verify that the bandwidth to the client increases when there are many objects inside the AOI and it decreases when there are few objects.

uTsung Testing - LOD Game

The game includes two files for running uTsung tests. They are named lod_game.xml and log_game.js. They are found in the folder LoadTestScripts in uTsungScriptFiles.zip.
Install uTsung on a Linux machine to be able to use the load test scripts. How to install uTsung and run tests configured in these two files is documented on the website here. Place both files in the folder “/usr/share/doc/tsung/examples”.
Edit two important things in the filen lod_game_xml.
  • Change the IP number to the IP number of the host where your uStream server is running.
  • Decide the number of player you want to simulate.
The script does not move the simultated players, they just stand still in this version of the script. But this is OK for basic load tests anyway because the traffic to the server is never a problem, it is the massive traffic going out from the server to the clients that is the bottleneck in high player density games. And massive outgoing traffic will happen when you use this script since all state synch data from all players and all NPCs are sent from the uStream server to all players (simulated by uStream).
The recommendced way to see what is happening during a load test is to do the following.
  1. Connect one real client to be able to see what one player session looks like during the load test.
  2. Run the two Windows tools “Task manager” and “Resource Monitor” to look at things like CPU and bandwidth (incoming and outgoing bandwidth per windows process) on the Windows host.