<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BakedOn Entertainment - Online Multiplayer Games &#187; Development</title>
	<atom:link href="http://www.bakedon.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bakedon.com</link>
	<description></description>
	<lastBuildDate>Fri, 23 Apr 2010 00:26:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to use Lidgren with Unity3D for MMOs &#8211; Part 1</title>
		<link>http://www.bakedon.com/2010/04/how-to-use-lidgren-with-unity3d-for-mmos-part-1/</link>
		<comments>http://www.bakedon.com/2010/04/how-to-use-lidgren-with-unity3d-for-mmos-part-1/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 23:58:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[lidgren]]></category>
		<category><![CDATA[MMORPG]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[udp]]></category>

		<guid isPermaLink="false">http://www.bakedon.com/?p=91</guid>
		<description><![CDATA[Why use Lidgren?
Don&#8217;t kid yourself.  Writing a multiplayer game that runs over the Internet can be tricky. If you are using Unity you have the entire .NET network library at your disposal. Simply making a TCP connection or sending UDP packets is pretty trivial. Why on earth would you bother using someone else&#8217;s library?

The debate [...]]]></description>
			<content:encoded><![CDATA[<h2>Why use Lidgren?</h2>
<p>Don&#8217;t kid yourself.  Writing a multiplayer game that runs over the Internet can be tricky. If you are using Unity you have the entire .NET network library at your disposal. Simply making a TCP connection or sending UDP packets is pretty trivial. Why on earth would you bother using someone else&#8217;s library?</p>
<p><span id="more-91"></span></p>
<p>The debate between TCP and UDP for MMOs is as strong as ever and I&#8217;m certainly not going to talk about it here. For <a href="http://www.ghostees.com">Ghostees</a>, I am using UDP and the <a title="Lidgren Network Library" href="http://code.google.com/p/lidgren-network/">Lidgren</a> library. It&#8217;s open source, free but best of all it solves a lot of the issues revolving around using UDP as your transport.</p>
<p>The types of things you can encounter with UDP can be a pain but since it is low level, you get incredible flexibility and performance.<a href="http://www.bakedon.com/wp-content/uploads/2010/04/Shoot-yourself-in-the-foot.jpg"><img class="alignright size-full wp-image-94" style="float: right;" title="Shoot yourself in the foot" src="http://www.bakedon.com/wp-content/uploads/2010/04/Shoot-yourself-in-the-foot.jpg" alt="" width="200" height="143" /></a> Think of UDP as a message passing protocol as opposed to TCP which is a stream based protocol.  TCP will ensure that your data makes its way across the trenches of the internet in tact and in order.  UDP on the other hand makes no guarantees.  Some messages may go missing.  You might even get two of the same or get messages out of order. Tricky stuff.  Lidgren takes care of all that stuff for your but only where you want it.  It will definitely let you shoot yourself in the foot also.</p>
<h2>The (very) Basic Server</h2>
<p>By the way, Lidgren builds in Mono so you can run your server on Linux. I&#8217;m pretty sure it works but I haven&#8217;t done enough testing to say 100% at this point and I&#8217;m pretty much a Windows guy. Enough yapping, lets get coding.</p>
<p>Start a new project for your server and create your server class. I prefer to add the Lidgren project to my solution but either way, add a reference to <strong>Lidgren.Network</strong>.</p>
<p>Your class will need two private members to start: NetServer and NetBuffer, both in the Lidgren.Network namespace.</p>
<pre class="brush: csharp;">
class MyServer
{
    private NetServer server;
    private NetBuffer buffer;

    public MyServer()
    {
        var config = new NetConfiguration(&quot;hello-world&quot;);
        config.Port = 42948;

        server = new NetServer(config);
        buffer = new NetBuffer();
        server.Start();
    }
}
</pre>
<p>Lets go through this quickly.  On line 3 the NetServer is the class from Lidgren that will listen for incoming traffic.  The NetBuffer on the next line is what we read our messages into.  We can reuse it so it is declared as a class member.</p>
<p>We create an instance of NetConfiguration to pass configuration information into the NetServer constructor. NetConfiguration takes a single string argument that is our application identifier.  This can be anything you like as long as both the client and server use the same string.</p>
<p><a href="http://www.bakedon.com/wp-content/uploads/2010/04/homer-doh.jpg"><img class="alignleft size-medium wp-image-112" title="homer-doh" src="http://www.bakedon.com/wp-content/uploads/2010/04/homer-doh-211x300.jpg" alt="" width="89" height="126" /></a><strong>DOH!</strong> you wouldn&#8217;t believe how many times I&#8217;ve had projects where I change the application identifier on either the client or server but not the other and then subsequently spend w-a-a-a-y too long trying to figure out why I can&#8217;t connect.</p>
<p>On line 9 I set the port that the server will listen on for incoming messages. Choose pretty much any number you like that is less than 65535 as long as it doesn&#8217;t conflict with another application listening on the same port. Only one port per network card can be in use at any time. You are best off choosing a number somewhere over 32768 to avoid &#8220;well known&#8221; ports.</p>
<p>Lastly, we just call Start() on the server to have it bind to the port and buffering messages.</p>
<h2>The Pump</h2>
<p><a href="http://www.bakedon.com/wp-content/uploads/2010/04/joeblowsport.jpg"><img class="alignright size-full wp-image-123" style="float: right;" title="joeblowsport" src="http://www.bakedon.com/wp-content/uploads/2010/04/joeblowsport.jpg" alt="" width="100" height="161" /></a>When the server receives a message, after some processing it places it into a queue. This all happens behind the scenes in another thread. You need to write code to retrieve them.  I usually have a single thread reading and distributing incoming messages and you might as well make it your main thread.  Add this method to your server class:</p>
<pre class="brush: csharp;">
    public void Process()
    {
        NetMessageType type;
        NetConnection source;

        while (server.ReadMessage(buffer, out type, out source))
        {
            HandleMessage(buffer, type, source);
        }
    }
</pre>
<p>Your server host, whether its a console application or Windows service, will be responsible for pumping the messages by calling Process. Avoid the temptation of over complicating your server with a thread for the message pump. You won&#8217;t see any speed or efficiency increase putting more threads in here.</p>
<p>Each time through the while loop, the server will hand you one message. It will also give you the type of message and which client connection it came from.</p>
<h2>The Mail Room</h2>
<p><a href="http://www.bakedon.com/wp-content/uploads/2010/04/Wood-36-Compartment-Mail-Sorter-7766GR_big.jpg"><img class="alignleft size-full wp-image-126" style="float: right;" title="Wood-36-Compartment-Mail-Sorter-(7766GR)_big" src="http://www.bakedon.com/wp-content/uploads/2010/04/Wood-36-Compartment-Mail-Sorter-7766GR_big.jpg" alt="" width="150" height="153" /></a>Now we need to decide what&#8217;s in the message we just got, and what to do with it. You will receive messages not only from your connected clients but also from Lidgren.  Lets cover Lidgren&#8217;s messages first.</p>
<p>Among the several types of messages Lidgren can send you, debug messages are one of the two basic ones you definitely want to handle. They will simply be strings that you can output to the console or debug stream.</p>
<p>Another  message you want to handle is the StatusChanged message. This message tells you when someone has connected or disconnected. I&#8217;ve created another method called HandleMessage which is where I will switch on the message type.</p>
<p>The last of the most basic messages is the Data message. These are messages sent to you from your connected clients.</p>
<p>I would suggest you throw an exception or at least log a warning if a message comes through that you didn&#8217;t handle. I&#8217;ve caught many weird bugs this way simply because I wasn&#8217;t aware I was receiving a BadMessageReceived or other message.</p>
<pre class="brush: csharp;">
    public event Action&lt;NetConnection&gt; ConnectionStatus;

    private void HandleMessage(NetBuffer buffer, NetMessageType type, NetConnection source)
    {
        switch (type)
        {
            case NetMessageType.DebugMessage:
                {
                    Debug.WriteLine(buffer.ReadString());
                    break;
                }

            case NetMessageType.StatusChanged:
                {
                    if (ConnectionStatus != null)
                        ConnectionStatus(source);
                    break;
                }

            case NetMessageType.Data:
                {
                    if (DataReceived != null)
                        DataReceived(source, buffer);
                    break;
                }

            default:
                throw new NotImplementedException(&quot;Message type not handled: &quot; + type.ToString());
        }
    }
</pre>
<p>You can see in the snippet above on the first two lines, I&#8217;ve declared two public events. Other classes in your server will want to know when a client comes and goes so its wise to publish this information. The other event gets fired when we receive data from clients.</p>
<p>HandleMessage works its magic by simply switching on the message type. In the case of a debug message, we simply write it to the debug stream.  In the case of a ConnectionStatus or Data message, we fire the appropriate events.</p>
<p>OK so here is the code so far:</p>
<pre class="brush: csharp;">
using System;
using System.Diagnostics;
using Lidgren.Network;

namespace BakedOn
{
    class MyServer
    {
        private NetServer server;
        private NetBuffer buffer;

        public event Action&lt;NetConnection&gt; ConnectionStatus;
        public event Action&lt;NetConnection, NetBuffer&gt; DataReceived;

        public MyServer()
        {
            var config = new NetConfiguration(&quot;hello-world&quot;);
            config.Port = 42948;

            server = new NetServer(config);
            buffer = server.CreateBuffer();
        }

        public void Process()
        {
            NetMessageType type;
            NetConnection source;

            while (server.ReadMessage(buffer, out type, out source))
            {
                HandleMessage(buffer, type, source);
            }
        }

        private void HandleMessage(NetBuffer buffer, NetMessageType type, NetConnection source)
        {
            switch (type)
            {
                case NetMessageType.DebugMessage:
                    {
                        Debug.WriteLine(buffer.ReadString());
                        break;
                    }

                case NetMessageType.StatusChanged:
                    {
                        if (ConnectionStatus != null)
                            ConnectionStatus(source);
                        break;
                    }

                case NetMessageType.Data:
                    {
                        if (DataReceived != null)
                            DataReceived(source, buffer);
                        break;
                    }

                default:
                    throw new NotImplementedException(&quot;Message type not handled: &quot; + type.ToString());
            }
        }
    }
}
</pre>
<p>In the next part, I will show you how to create a client that will work within Unity. It&#8217;s not tough at all. And if you deep-tech readers are concerned what we have done here is far too simplistic, not to worry. We will be going much deeper. After the client, we will start talking about message formats, serialization and message envelopes.</p>
<p>If this topic is useful or interesting to you, shoot me a quick comment and let me know so I&#8217;ll keep going with it.</p>
<ul class="socialwrap row">
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F04%2Fhow-to-use-lidgren-with-unity3d-for-mmos-part-1%2F&amp;title=How+to+use+Lidgren+with+Unity3D+for+MMOs+%26%238211%3B+Part+1" title="Save on Delicious How to use Lidgren with Unity3D for MMOs &#8211; Part 1"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/delicious.png" height="16"  width="16" /> <span class="head">Bookmark on Delicious</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F04%2Fhow-to-use-lidgren-with-unity3d-for-mmos-part-1%2F&amp;title=How+to+use+Lidgren+with+Unity3D+for+MMOs+%26%238211%3B+Part+1" title="Digg this post - How to use Lidgren with Unity3D for MMOs &#8211; Part 1"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/digg.png" height="16"  width="16" /> <span class="head">Digg this post</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.bakedon.com%2F2010%2F04%2Fhow-to-use-lidgren-with-unity3d-for-mmos-part-1%2F&#038;t=How+to+use+Lidgren+with+Unity3D+for+MMOs+%26%238211%3B+Part+1" title="Share this post - How to use Lidgren with Unity3D for MMOs &#8211; Part 1"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/facebook.png" height="16"  width="16" /> <span class="head">Recommend on Facebook</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F04%2Fhow-to-use-lidgren-with-unity3d-for-mmos-part-1%2F&amp;title=How+to+use+Lidgren+with+Unity3D+for+MMOs+%26%238211%3B+Part+1" title="Share on Reddit: How to use Lidgren with Unity3D for MMOs &#8211; Part 1"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/reddit.png" height="16"  width="16" /> <span class="head">share via Reddit</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F04%2Fhow-to-use-lidgren-with-unity3d-for-mmos-part-1%2F&amp;title=How+to+use+Lidgren+with+Unity3D+for+MMOs+%26%238211%3B+Part+1" title="Submit to Stumble: How to use Lidgren with Unity3D for MMOs &#8211; Part 1"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/stumbleupon.png" height="16"  width="16" /> <span class="head">Share with Stumblers</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://twitter.com/home/?status=http%3A%2F%2Fwww.bakedon.com%2F2010%2F04%2Fhow-to-use-lidgren-with-unity3d-for-mmos-part-1%2F" title="Tweet this post : How to use Lidgren with Unity3D for MMOs &#8211; Part 1"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/twitter.png" height="16"  width="16" /> <span class="head">Tweet about it</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://www.bakedon.com/2010/04/how-to-use-lidgren-with-unity3d-for-mmos-part-1/feed" title="Track this post - How to use Lidgren with Unity3D for MMOs &#8211; Part 1 - via RSS"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/rss.png" height="16"  width="16" /> <span class="head">Subscribe to the comments on this post</span></a></li>
</ul>
<div class="clean"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bakedon.com/2010/04/how-to-use-lidgren-with-unity3d-for-mmos-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Untiy3D Asynchronous Sockets</title>
		<link>http://www.bakedon.com/2010/03/untiy3d-asynchronous-sockets/</link>
		<comments>http://www.bakedon.com/2010/03/untiy3d-asynchronous-sockets/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 20:31:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://www.bakedon.com/?p=85</guid>
		<description><![CDATA[

You can download this project here.

There is a lot of discussion on whether you can use threading or asynchronous sockets with Unity3D and with the web player in particular.
I&#8217;ve created this sample project to demonstrate how this is done.  You&#8217;ll see above that when you run it, the project attempts to make several asynchronous connections [...]]]></description>
			<content:encoded><![CDATA[<div><a href="http://www.bakedon.com/wp-content/uploads/2010/03/unity-async-output.jpg"><img class="size-full wp-image-144 aligncenter" title="Unity3d asynchronous sockets" src="http://www.bakedon.com/wp-content/uploads/2010/03/unity-async-output.jpg" alt="" width="312" height="240" /></a></div>
<div class="download">
You can download <a href="http://www.bakedon.com/unity/asyncsocket/AsyncSocketTest.zip">this project here</a>.<br/><br/>
</div>
<p>There is a lot of discussion on whether you can use threading or asynchronous sockets with Unity3D and with the web player in particular.</p>
<p>I&#8217;ve created this sample project to demonstrate how this is done.  You&#8217;ll see above that when you run it, the project attempts to make several asynchronous connections to web servers and download their default page.</p>
<p>There are a couple of basic things you should watch out for:</p>
<ol>
<li>Calls to Unity object or the UnityEngine API must be done on the main Unity application thread. You will need to martial values back to that thread. In this example, you&#8217;ll notice I don&#8217;t update the GUIText text value directly.  I update my own internal status string and only update the GUIText during an Update( ) call.</li>
<li>You need to shut down your socket and thread operations when OnApplicaitonQuit( ) is called. Exceptions may be thrown on any asychronous callback and you need to be sure to catch and handle these.</li>
</ol>
<ul class="socialwrap row">
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F03%2Funtiy3d-asynchronous-sockets%2F&amp;title=Untiy3D+Asynchronous+Sockets" title="Save on Delicious Untiy3D Asynchronous Sockets"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/delicious.png" height="16"  width="16" /> <span class="head">Bookmark on Delicious</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F03%2Funtiy3d-asynchronous-sockets%2F&amp;title=Untiy3D+Asynchronous+Sockets" title="Digg this post - Untiy3D Asynchronous Sockets"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/digg.png" height="16"  width="16" /> <span class="head">Digg this post</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.bakedon.com%2F2010%2F03%2Funtiy3d-asynchronous-sockets%2F&#038;t=Untiy3D+Asynchronous+Sockets" title="Share this post - Untiy3D Asynchronous Sockets"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/facebook.png" height="16"  width="16" /> <span class="head">Recommend on Facebook</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F03%2Funtiy3d-asynchronous-sockets%2F&amp;title=Untiy3D+Asynchronous+Sockets" title="Share on Reddit: Untiy3D Asynchronous Sockets"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/reddit.png" height="16"  width="16" /> <span class="head">share via Reddit</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F03%2Funtiy3d-asynchronous-sockets%2F&amp;title=Untiy3D+Asynchronous+Sockets" title="Submit to Stumble: Untiy3D Asynchronous Sockets"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/stumbleupon.png" height="16"  width="16" /> <span class="head">Share with Stumblers</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://twitter.com/home/?status=http%3A%2F%2Fwww.bakedon.com%2F2010%2F03%2Funtiy3d-asynchronous-sockets%2F" title="Tweet this post : Untiy3D Asynchronous Sockets"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/twitter.png" height="16"  width="16" /> <span class="head">Tweet about it</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://www.bakedon.com/2010/03/untiy3d-asynchronous-sockets/feed" title="Track this post - Untiy3D Asynchronous Sockets - via RSS"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/rss.png" height="16"  width="16" /> <span class="head">Subscribe to the comments on this post</span></a></li>
</ul>
<div class="clean"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bakedon.com/2010/03/untiy3d-asynchronous-sockets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ghostees: Load Testing The Server</title>
		<link>http://www.bakedon.com/2010/01/ghostees-load-testing-the-server/</link>
		<comments>http://www.bakedon.com/2010/01/ghostees-load-testing-the-server/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 21:01:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Ghostees]]></category>
		<category><![CDATA[MMORPG]]></category>
		<category><![CDATA[unity3d]]></category>

		<guid isPermaLink="false">http://www.bakedon.com/?p=68</guid>
		<description><![CDATA[I created this video while I was testing the connection load of the server.  Each capsule you see is an automated connection moving randomly through the world. Since then I have changed them to actual character animations which looks way cooler but I haven&#8217;t taken time to record a video.
The server culls down how [...]]]></description>
			<content:encoded><![CDATA[<p>I created this video while I was testing the connection load of the server.  Each capsule you see is an automated connection moving randomly through the world. Since then I have changed them to actual character animations which looks way cooler but I haven&#8217;t taken time to record a video.</p>
<p><span id="more-68"></span>The server culls down how many entities the game client will see so not to overload it.  On the server I have masks that are used to categorize and prioritize what needs to be seen on any client.  Click the video to head on over to youtube.com and watch it in HD.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="292" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/kCp2-nfibzY&amp;hl=en_US&amp;fs=1&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="292" src="http://www.youtube.com/v/kCp2-nfibzY&amp;hl=en_US&amp;fs=1&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><!--more-->As of this writing, I&#8217;ve had the server up to 400 concurrent connections @ 50% cpu but in the next build I think I can double that performance.  There are many optimizations I know I can do at this point. Load has a lot to do with the number of entities that can see each other at any one time which corresponds to the number of messages I need to generate.</p>
<p>The chart below is with 95 connected entities that can all literally see each other.</p>
<p><a href="http://www.bakedon.com/wp-content/uploads/2010/01/load-with-95-npc-connections.jpg"><img class="alignnone size-medium wp-image-72" title="Server load with 95 npc connections" src="http://www.bakedon.com/wp-content/uploads/2010/01/load-with-95-npc-connections-279x300.jpg" alt="" width="279" height="300" /></a></p>
<p>As it is in that video, every entity can see every other entity within a vision radius. To achieve the 400 connections, I reduced the vision radius of NPCs and left the larger radius for actual players. This is where the masking comes in.  NPCs don&#8217;t really care about a lot of entities.  They may not care about any entities of their same race for instance.  They may only care about players or perhaps even entities of a race they are at war with.  The mask is simply a set of flags that determine who they care about seeing.  Combine this with an appropriate vision radius.  For instance, NPC&#8217;s don&#8217;t have to see as far as players. They only need to see as far as their maximum aggro radius.  On the other hand, players need to see further so that characters don&#8217;t magically warp in.</p>
<p>World design also plays a part in controlling this.  If you can see a great distance in front of you at any one time, you could potentially see a lot of entities.  Have a look carefully at the design of Orgimmar or Iron Forge in World of Warcraft.  Also think about how dungeon instances are designed. These areas are designed either to manage a high density of players or to keep game latency down to a minimum by carefully managing your visual distance.  This will keep both the client and server snappy.</p>
<p>If you have other ideas for managing this, I&#8217;d love to hear them. Please post a comment!</p>
<ul class="socialwrap row">
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F01%2Fghostees-load-testing-the-server%2F&amp;title=Ghostees%3A+Load+Testing+The+Server" title="Save on Delicious Ghostees: Load Testing The Server"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/delicious.png" height="16"  width="16" /> <span class="head">Bookmark on Delicious</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F01%2Fghostees-load-testing-the-server%2F&amp;title=Ghostees%3A+Load+Testing+The+Server" title="Digg this post - Ghostees: Load Testing The Server"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/digg.png" height="16"  width="16" /> <span class="head">Digg this post</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.bakedon.com%2F2010%2F01%2Fghostees-load-testing-the-server%2F&#038;t=Ghostees%3A+Load+Testing+The+Server" title="Share this post - Ghostees: Load Testing The Server"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/facebook.png" height="16"  width="16" /> <span class="head">Recommend on Facebook</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F01%2Fghostees-load-testing-the-server%2F&amp;title=Ghostees%3A+Load+Testing+The+Server" title="Share on Reddit: Ghostees: Load Testing The Server"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/reddit.png" height="16"  width="16" /> <span class="head">share via Reddit</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2010%2F01%2Fghostees-load-testing-the-server%2F&amp;title=Ghostees%3A+Load+Testing+The+Server" title="Submit to Stumble: Ghostees: Load Testing The Server"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/stumbleupon.png" height="16"  width="16" /> <span class="head">Share with Stumblers</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://twitter.com/home/?status=http%3A%2F%2Fwww.bakedon.com%2F2010%2F01%2Fghostees-load-testing-the-server%2F" title="Tweet this post : Ghostees: Load Testing The Server"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/twitter.png" height="16"  width="16" /> <span class="head">Tweet about it</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://www.bakedon.com/2010/01/ghostees-load-testing-the-server/feed" title="Track this post - Ghostees: Load Testing The Server - via RSS"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/rss.png" height="16"  width="16" /> <span class="head">Subscribe to the comments on this post</span></a></li>
</ul>
<div class="clean"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bakedon.com/2010/01/ghostees-load-testing-the-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unity3d Additive Projector with Alpha Blend</title>
		<link>http://www.bakedon.com/2009/09/unity3d-additive-projector-with-alpha-blend/</link>
		<comments>http://www.bakedon.com/2009/09/unity3d-additive-projector-with-alpha-blend/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 02:34:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[shaders]]></category>
		<category><![CDATA[unity3d]]></category>

		<guid isPermaLink="false">http://www.bakedon.com/?p=61</guid>
		<description><![CDATA[Tonight I worked on learning the basics of Unity3D&#8217;s GUI system.  It&#8217;s suprisingly easy to use.
I also worked on projecting zodiac effects onto a plane which was suprisingly difficult. I managed to find a shader that does this [need link!].

http://bakedon.com/unity/projection



 Bookmark on Delicious
 Digg this post
 Recommend on Facebook
 share via Reddit
 Share with Stumblers
 [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight I worked on learning the basics of Unity3D&#8217;s GUI system.  It&#8217;s suprisingly easy to use.</p>
<p>I also worked on projecting zodiac effects onto a plane which was suprisingly difficult. I managed to find a shader that does this [need link!].</p>
<div class="preview">
<a href="http://bakedon.com/unity/projection">http://bakedon.com/unity/projection</a><br/><br/>
</div>
</p>
<ul class="socialwrap row">
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.bakedon.com%2F2009%2F09%2Funity3d-additive-projector-with-alpha-blend%2F&amp;title=Unity3d+Additive+Projector+with+Alpha+Blend" title="Save on Delicious Unity3d Additive Projector with Alpha Blend"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/delicious.png" height="16"  width="16" /> <span class="head">Bookmark on Delicious</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bakedon.com%2F2009%2F09%2Funity3d-additive-projector-with-alpha-blend%2F&amp;title=Unity3d+Additive+Projector+with+Alpha+Blend" title="Digg this post - Unity3d Additive Projector with Alpha Blend"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/digg.png" height="16"  width="16" /> <span class="head">Digg this post</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.bakedon.com%2F2009%2F09%2Funity3d-additive-projector-with-alpha-blend%2F&#038;t=Unity3d+Additive+Projector+with+Alpha+Blend" title="Share this post - Unity3d Additive Projector with Alpha Blend"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/facebook.png" height="16"  width="16" /> <span class="head">Recommend on Facebook</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2009%2F09%2Funity3d-additive-projector-with-alpha-blend%2F&amp;title=Unity3d+Additive+Projector+with+Alpha+Blend" title="Share on Reddit: Unity3d Additive Projector with Alpha Blend"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/reddit.png" height="16"  width="16" /> <span class="head">share via Reddit</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2009%2F09%2Funity3d-additive-projector-with-alpha-blend%2F&amp;title=Unity3d+Additive+Projector+with+Alpha+Blend" title="Submit to Stumble: Unity3d Additive Projector with Alpha Blend"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/stumbleupon.png" height="16"  width="16" /> <span class="head">Share with Stumblers</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://twitter.com/home/?status=http%3A%2F%2Fwww.bakedon.com%2F2009%2F09%2Funity3d-additive-projector-with-alpha-blend%2F" title="Tweet this post : Unity3d Additive Projector with Alpha Blend"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/twitter.png" height="16"  width="16" /> <span class="head">Tweet about it</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://www.bakedon.com/2009/09/unity3d-additive-projector-with-alpha-blend/feed" title="Track this post - Unity3d Additive Projector with Alpha Blend - via RSS"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/rss.png" height="16"  width="16" /> <span class="head">Subscribe to the comments on this post</span></a></li>
</ul>
<div class="clean"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bakedon.com/2009/09/unity3d-additive-projector-with-alpha-blend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ghostees: Meet the Grave Digger</title>
		<link>http://www.bakedon.com/2008/03/ghostees-meet-the-grave-digger/</link>
		<comments>http://www.bakedon.com/2008/03/ghostees-meet-the-grave-digger/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 03:49:51 +0000</pubDate>
		<dc:creator>Tricky</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.bakedon.com/2008/03/ghostees-meet-the-grave-digger/</guid>
		<description><![CDATA[The core animations for most of the characters were rendered this week. One of the balancing acts you have to perform is the quality of the animation verses the size of the download. I can tell you now, Ghostees is going to be a demanding game for your processor and bandwidth but the eye candy [...]]]></description>
			<content:encoded><![CDATA[<p>The core animations for most of the characters were rendered this week. One of the balancing acts you have to perform is the quality of the animation verses the size of the download. I can tell you now, Ghostees is going to be a demanding game for your processor and bandwidth but the eye candy is certainly worth it. I&#8217;ve developed a number of techniques to ease the burden on bandwidth. Luckily a lot of the content will be cached by the browser so subsequent loads will be kinder to your patience. I&#8217;m even going to offer an <a title="Adobe AIR Runtime for Ghostees" href="http://www.adobe.com/products/air/" target="_blank">Adobe AIR</a> version for anyone that might be feeling the pinch.<span id="more-28"></span></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="128" height="128" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="diggertalk" /><param name="bgcolor" value="#ffffff" /><param name="align" value="middle" /><param name="src" value="/wp-content/themes/revolution-20/flash/diggertalk.swf" /><embed type="application/x-shockwave-flash" width="128" height="128" src="/wp-content/themes/revolution-20/flash/diggertalk.swf" align="middle" bgcolor="#ffffff" name="diggertalk"></embed></object></p>
<p>I wired up the foundation for server audited and filtered chat. Essentially when a player sends a chat message, it routes through the server first to be filtered. The server can modify or completely reject the text.  If the text passes the server gauntlet, the server drops the text to the auditor service and then broadcasts the message to all applicable players.</p>
<p>Next I needed to take the World View class and create various layers for the visuals to appear on.  Actually, two layers were already there (background and content layers) but I needed to add an overlay layer and made the decision to bundle them together in a unifying container.  This caused some wierd offset calculation issues that I won&#8217;t bother explaining but caused me an hour or two of head scratching to figure it out.  The talk bubbles show up on the overlay layer so they won&#8217;t be obscured an voila, I have chat.</p>
<p>I&#8217;m using the new <a title="Adobe Flex Builder 3" href="http://www.adobe.com/products/flex/" target="_blank">Flex Builder 3</a> as my Flash development environment. There are some good bug fixes but actually not a ton of new stuff <strong><em>except</em></strong> the profiling capabilities. This is the sole reason I upgraded. I gave these features a whirl and found some nice optimizations.</p>
<ul class="socialwrap row">
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.bakedon.com%2F2008%2F03%2Fghostees-meet-the-grave-digger%2F&amp;title=Ghostees%3A+Meet+the+Grave+Digger" title="Save on Delicious Ghostees: Meet the Grave Digger"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/delicious.png" height="16"  width="16" /> <span class="head">Bookmark on Delicious</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bakedon.com%2F2008%2F03%2Fghostees-meet-the-grave-digger%2F&amp;title=Ghostees%3A+Meet+the+Grave+Digger" title="Digg this post - Ghostees: Meet the Grave Digger"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/digg.png" height="16"  width="16" /> <span class="head">Digg this post</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.bakedon.com%2F2008%2F03%2Fghostees-meet-the-grave-digger%2F&#038;t=Ghostees%3A+Meet+the+Grave+Digger" title="Share this post - Ghostees: Meet the Grave Digger"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/facebook.png" height="16"  width="16" /> <span class="head">Recommend on Facebook</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2008%2F03%2Fghostees-meet-the-grave-digger%2F&amp;title=Ghostees%3A+Meet+the+Grave+Digger" title="Share on Reddit: Ghostees: Meet the Grave Digger"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/reddit.png" height="16"  width="16" /> <span class="head">share via Reddit</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bakedon.com%2F2008%2F03%2Fghostees-meet-the-grave-digger%2F&amp;title=Ghostees%3A+Meet+the+Grave+Digger" title="Submit to Stumble: Ghostees: Meet the Grave Digger"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/stumbleupon.png" height="16"  width="16" /> <span class="head">Share with Stumblers</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://twitter.com/home/?status=http%3A%2F%2Fwww.bakedon.com%2F2008%2F03%2Fghostees-meet-the-grave-digger%2F" title="Tweet this post : Ghostees: Meet the Grave Digger"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/twitter.png" height="16"  width="16" /> <span class="head">Tweet about it</span></a></li>
<li class="iconOnly"><a rel="nofollow" target="_blank" href="http://www.bakedon.com/2008/03/ghostees-meet-the-grave-digger/feed" title="Track this post - Ghostees: Meet the Grave Digger - via RSS"><img src="http://www.bakedon.com/wp-content/plugins/share-and-follow/default/16/rss.png" height="16"  width="16" /> <span class="head">Subscribe to the comments on this post</span></a></li>
</ul>
<div class="clean"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bakedon.com/2008/03/ghostees-meet-the-grave-digger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
