<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>robotduck</title>
	<atom:link href="http://robotduck.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://robotduck.wordpress.com</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2012 09:43:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='robotduck.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>robotduck</title>
		<link>http://robotduck.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://robotduck.wordpress.com/osd.xml" title="robotduck" />
	<atom:link rel='hub' href='http://robotduck.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Code Optimization in Unity : Part 2</title>
		<link>http://robotduck.wordpress.com/2011/08/05/code-optimization-in-unity-part-2/</link>
		<comments>http://robotduck.wordpress.com/2011/08/05/code-optimization-in-unity-part-2/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 17:11:21 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[optimization unity script timing time profiler]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=395</guid>
		<description><![CDATA[&#8220;By measurement to knowledge&#8221; So, in part 1 we saw a few examples of the output from the Profiler window in Unity Pro. If you have Pro, this built-in profiler can be incredibly useful in determining whether your code is taking up a significant amount of time, and if so, which scripts and functions in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=395&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.google.com/search?q=%22by+measurement+to+knowledge%22+Heike+Kamerlingh+Onnes+quote"><strong>&#8220;By measurement to knowledge&#8221;</strong></a></p>
<p>So, in part 1 we saw a few examples of the output from the Profiler window in Unity Pro. If you have Pro, this <a href="http://unity3d.com/support/documentation/Manual/Profiler.html" target="_blank">built-in profiler</a> can be incredibly useful in determining whether your code is taking up a significant amount of time, and if so, which scripts and functions in particular are responsible. There are also other professional code profilers available for other development environments, such as <a href="http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/" target="_blank">Red Gate&#8217;s &#8220;ANTS&#8221;</a> which will literally give you a speed recording for every line of code in your project. These types of tools are invaluable if you have the budget for them, but many don&#8217;t have access to such tools, particularly beginners and budding indie developers. However, all is not lost &#8211; it&#8217;s actually possible to measure the speed of your own code within the code itself.</p>
<p>In a nutshell, you can achieve this by simply recording the time before and after the code is executed. In practice there are a few more hurdles involved in getting sensible and useful recordings which I will talk through over the course of this post, however this is the fundamental concept &#8211; so the first thing you need to know is how to record time.</p>
<p><em>I&#8217;m aware that my previous post attracted the attention of some non-Unity readers, I will try to make as much of this post relevant to all languages as possible, however it will remain largely Unity-centric!</em></p>
<p>Unity provides you with the <a href="http://unity3d.com/support/documentation/ScriptReference/Time.html" target="_blank">Time</a> class for dealing with time, and pretty much all languages have the equivalent of a &#8220;current time&#8221; system property. In regular C# (in or outside of Unity) you can use <a href="http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx" target="_blank">DateTime.Now.Ticks</a>, and in Flash&#8217;s Actionscript, there&#8217;s <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html#getTimer%28%29" target="_blank">getTimer()</a>. The concepts from here on are fairly simple so you should be able to adapt them to any language of your choice.</p>
<p>Before we get started though, it&#8217;s important to know one thing about your time variable before you use it &#8211; whether it can return a changing value when called multiple times during the execution of a function. In Unity, the most commonly used time properties, &#8220;Time.deltaTime&#8221; and &#8220;Time.time&#8221; <em>do not</em> update over the duration of a function. Instead, they only get a new value each frame, and they keep that value until the entire frame has completed. Because of this, they are useless for profiling code within a function!</p>
<p>For example, if we wanted to measure the contents of our Player&#8217;s &#8220;Update()&#8221; function, we might try something like this, where we record the time before and after the contents of the Update() function, and compare the difference:</p>
<p><pre class="brush: csharp; light: true;">
void Update() {

	float startTime = Time.time;

	// (Some code here which you want to measure)

	float endTime = Time.time;
	float timeElapsed = (endTime-startTime);

}
</pre></p>
<p>With the above example, startTime and endTime will always have the same value, because Unity&#8217;s Time.time does not change while the function is being executed &#8211; which is obviously no use at all because the measured time difference would always equal zero! Instead however, you can use the lesser-known property on the same class: <a href="http://unity3d.com/support/documentation/ScriptReference/Time-realtimeSinceStartup.html">Time.realtimeSinceStartup</a>. This is very useful because not only does it update during the course of a function running, but it is also not affected by your current timescale setting, so it won&#8217;t be affected if you&#8217;re using slow-motion or other time-stretching effects in your game. If you&#8217;re working in something other than Unity 3D, make sure your time function has this important feature!</p>
<p>So to make a measurement, we record the realtimeSinceStartup value before and after the code, and simply subtract the latter from the former like this:</p>
<p><pre class="brush: csharp; light: true;">
void Update() {

	float startTime = Time.realtimeSinceStartup;

	// (Some code here which you want to measure)

	float endTime = Time.realtimeSinceStartup;
	float timeElapsed = (endTime-startTime);

}
</pre></p>
<p>Now any single timing of the same code is likely to fluctuate a certain amount, and the smaller the timescale that you&#8217;re trying to measure, the larger the fluctuations will be in comparison. Depending on what you&#8217;re measuring, this amount of time elapsed may be very very small &#8211; even down to hundredths of a millisecond or less &#8211; so to get a sensible reading it&#8217;s best to record the same action lots of times and average the result.</p>
<p>One way to do this would be to simply use a tight &#8220;for&#8221; or &#8220;while&#8221; loop which repeats the enclosed code a few thousand times. This is fine if you want to quickly test a certain section of code in isolation but it&#8217;s not so useful when trying to profile your game while it&#8217;s being played in a normal way (eg, baddies moving, bullets flying around, etc). So, to expand on the example that I&#8217;ve started building above, to accumulate and average the recordings of our Update function over a larger time period, we could do something like this, which records the time taken to perform the function 500 times (once per frame), and then outputs the result to Unity&#8217;s console window:</p>
<p><pre class="brush: csharp; light: true;">
int numRecordings = 500; // number of recordings to make
float timeRecorded = 0;  // total accumulated time
int recordingNum = 0;    // current recording number

void Update() {

	float startTime = Time.realtimeSinceStartup;

	// (the code here that you want to measure)

	float endTime = Time.realtimeSinceStartup;

	// this section now accumulates the time, and
	// computes the average once we hit the required
	// number of recordings:

	float timeElapsed = (endTime-startTime);
	recordingNum++;
	timeRecorded += timeElapsed;
	if (recordingNum == numRecordings) {

		// calculate and display the average time
		float averageTime = timeRecorded/numRecordings;
		Debug.Log(&quot;Avg Time: &quot;+averageTime+&quot; seconds&quot;);

		// and finally, reset &amp; repeat:
		recordingNum = 0;
		timeRecording = 0;
	}
}
</pre></p>
<p>Now we&#8217;re getting somewhere. With this in place, we can get a good idea of the time taken to execute any block of code that we might care about. Note that it doesn&#8217;t have to be your Update function that is measured. You might be interested in, for example, how long it&#8217;s taking a particular single line your Instantiate function to execute. In this case, you could put the &#8220;startTime&#8221; and &#8220;endTime&#8221; recordings either side of this single line, like this:</p>
<p><pre class="brush: csharp; light: true;">
	float startTime = Time.realtimeSinceStartup;
	Instantiate(enemyPrefab, pos, rot);
	float endTime = Time.realtimeSinceStartup;
</pre></p>
<p>The main problem with the method above is that while it works, it would be impractical, messy and confusing to duplicate all this code to each and every Update function, and to every other part of your program that you want to measure in your project. Aren&#8217;t you thinking it would be so much better if we could encapsulate the system used here into a simple friendly portable class? So am I!</p>
<p>The next example does just this. It&#8217;s a class I have written called &#8220;CodeProfiler&#8221; which is designed to be placed on an empty GameObject in your scene. For those working in a different engine and unfamiliar with Unity&#8217;s conventions, this basically means that the class will be automatically instantiated, and it receives Start() and Update() events automatically from the Unity engine while playing. The reason it requires these events is so that it can accumulate and average the overall frame rate which is then used as a comparison with your own chosen measurements. It has two public functions, &#8220;Begin&#8221; and &#8220;End&#8221; which you can call at the beginning and end of any particular code you want to profile. These functions are <em>static</em>, which means you can call them directly just by using the class name as a prefix &#8211; so there is no need to find references to the profiler GameObject or script instance.</p>
<p>The full code for the CodeProfiler class is included at the bottom of this post, but first I&#8217;m going to explain how to use it and how it works. The script is written in C#, but you can call it from both C# scripts <em>and scripts written in Unity&#8217;s Javascript</em> if you place it the <a href="http://answers.unity3d.com/questions/10856/cant-find-namespace-accessing-javascript-from-c-or.html">appropriate folder</a>.</p>
<p>In order to differentiate between the various parts of code that you want to measure, you pass an ID to these Begin and End functions &#8211; which is nothing more complex than a name, as a string parameter. You are essentially just picking a label to name each different reading that is taking place in your code. For example, if &#8211; in your game &#8211; you wanted to measure the speed of each your Player&#8217;s, Enemy&#8217;s and Bullet&#8217;s update functions, you could add the Begin and End functions in your code like this:</p>
<p><pre class="brush: csharp; light: true;">
// Player Script:
void Update()
{
	CodeProfiler.Begin(&quot;Player:Update&quot;);

	// (The rest of your Player update code here)

	CodeProfiler.End(&quot;Player:Update&quot;);
}
</pre></p>
<p>&nbsp;</p>
<p><pre class="brush: csharp; light: true;">
// Enemy Script:
void Update()
{
	CodeProfiler.Begin(&quot;Enemy:Update&quot;);

	// (The rest of your Enemy update code here)

	CodeProfiler.End(&quot;Enemy:Update&quot;);
}
</pre></p>
<p>&nbsp;</p>
<p><pre class="brush: csharp; light: true;">
// Bullet Script:
void Update()
{
	CodeProfiler.Begin(&quot;Bullet:Update&quot;);

	// (The rest of your Bullet update code here)

	CodeProfiler.End(&quot;Bullet:Update&quot;);
}
</pre></p>
<p>So you can see in the above examples, I&#8217;ve picked the labels &#8220;Player:Update&#8221;, &#8220;Enemy:Update&#8221;, and &#8220;Bullet:Update&#8221; for my 3 entries in the code profiler. I&#8217;ve chosen a convention of &#8220;ClassName:FunctionName&#8221; but you could use whatever you like as long as each entry is unique. Now all that remains to do is to make sure that my CodeProfiler script is actually placed on an empty gameobject in the scene, and hit Play in the Unity editor.</p>
<p>The CodeProfiler updates its results every 5 seconds (the results are the average of the readings over those five seconds), and they look like this:</p>
<p><pre class="brush: plain; light: true;">
Avg frame time: 19.6ms, 51 fps
Total     MS/frame  Calls/frame MS/call   Label
0.467%    0.092ms   1.000       0.0933ms  Player:Update
6.429%    1.260ms   6.000       0.2101ms  Enemy:Update
4.036%    0.791ms   16.480      0.0480ms  Bullet:Update
</pre></p>
<p>The first line gives you the average time elapsed per frame, and the corresponding &#8220;frames per second&#8221; that this results in. This includes everything &#8211; rendering, physics, scripts, etc.</p>
<p>Underneath are your individual readings for each &#8220;ID&#8221; that you used when measuring your code. In this example, the three IDs I mentioned earlier are present. Each entry has the following figures:</p>
<p>&#8220;Total&#8221; shows the percentage time taken of the whole frame time.<br />
&#8220;MS/Frame&#8221; shows the amount of milliseconds spent on this task per frame. This is the sum if there were multiple calls (for example if multiple enemies all recorded their Update times under the same ID).<br />
&#8220;Calls/Frame&#8221; tells you the average number of times this reading was measured per frame. In my example, for the player it&#8217;s 1. For the Enemy, it&#8217;s 6, because there were 6 enemies present during the test all recording their time against the same ID. For the Bullets it&#8217;s the same situation, but this time it&#8217;s not a whole number, because the number of bullets present varied over the duration of the 5 seconds measured, but it averaged about 16.<br />
And finally, &#8220;MS/call&#8221; tells you how long each individual call took, on average. This is basically MS/Frame divided by Calls/frame.</p>
<p>These statistics give you some means to assess what impact your scripts are having in terms of your game&#8217;s overall performance. A game that is having performance trouble might come out looking something like this:</p>
<p><pre class="brush: plain; light: true;">
Avg frame time: 110.1ms, 9.1 fps
Total     MS/frame  Calls/fra MS/call   Label
0.285%    0.314ms   5.500     0.0570ms  Player:FixedUpdate
79.270%   87.275ms  107.022   0.8155ms  Bullet:Update
0.004%    0.004ms   1.000     0.0045ms  Level:Update
5.604%    6.170ms   56.283    0.1096ms  Enemy:FixedUpdate
0.900%    0.991ms   2.413     0.4107ms  Enemy:FireBullet
</pre></p>
<p>Uh-oh &#8211; there are serious problems here: the game is running at around nine frames per second. My CodeProfiler doesn&#8217;t measure the time taken for physics and rendering, but it does measure the total frame time, and we can see from the results that the bullet&#8217;s Update function is by far dominating the total time taken per frame. The bullet&#8217;s update function is also being called many times &#8211; an average of 107 bullets per frame, each having its Update function called every frame, for this particular 5 second time-slice. This wouldn&#8217;t be so bad if their individual execution time was very fast (which it should be, for a bullet!), however an average of 0.8155ms per call is a long time, so there is clearly something wrong within that function which &#8211; when multiplied by every active bullet &#8211; causes a huge slowdown.</p>
<p>You might also notice at the bottom of the list that I added an entry for &#8220;Enemy:FireBullet&#8221;, which is a sub-section of the enemy&#8217;s code which is responsible for instantiating and calculating the trajectory for each individual bullet, to see whether that was the problem. I did that by simply adding another call to CodeProfiler.Begin() and CodeProfiler.End() around just that section of code, and choosing the label &#8220;Enemy:FireBullet&#8221;. The results show that approximately 2.4 bullets were fired per frame, but the code for this only totalled 0.9% of the frame time, so this clearly isn&#8217;t the cause of the poor framerate.</p>
<p>So from this example we can clearly see the problem lies within the bullet&#8217;s Update function, and it&#8217;s not the instantiation of the bullet. If this was your project, you could narrow it down further by adding Begin() and End() calls around smaller parts within the offending code until you can identify what exactly is the major time-consumer in there. It&#8217;s very common for for the most time to be taken up by very few or even a single element of your code.</p>
<p>If all your code readings add up to a small portion of the total frame time, but your game is still running slowly, you know the major costs are elsewhere &#8211; i.e. graphics and/or physics.</p>
<p>How does the CodeProfiler work? Basically it uses a type of collection called a &#8220;Dictionary&#8221; to store multiple recordings. A dictionary is a bit like an array, however it stores key/value pairs rather than a simple list of values. (<a title="Unity Coding: Arrays, Hashtables and Dictionaries explained" href="http://robotduck.wordpress.com/2009/11/04/88/">Read more about Dictionaries and other types of arrays and collections in Unity here</a>). The &#8220;key&#8221; is the string ID that you choose, and the &#8220;value&#8221; is an instance of the accompanying class &#8220;ProfileRecording&#8221;. This ProfileRecording class contains just a few variables and functions which allow it to act as a simple stopwatch. The CodeProfiler class creates a new ProfileRecording instance each time it encounters an ID which isn&#8217;t yet present in the dictionary, and adds the instance to the dictionary under the given ID. The CodeProfiler uses Unity&#8217;s OnGUI functions to display the text on-screen each frame, and each time the &#8220;nextOutputTime&#8221; is reached, the results are calculated and the text displayed is updated.</p>
<p>When you call the Begin and End function function with an ID, the CodeProfiler looks up the ProfileRecording associated with that ID in the dictionary, and calls the corresponding Start or Stop function on it. Each individial ProfileRecording instance in the dictionary keeps track of how much time it has accumulated. The ProfileRecording class has a Reset function to allow it to begin a fresh recording when required, and also generates an error if the Start and Stop functions are called out-of-order.</p>
<p>(<em>I&#8217;m aware that .Net actually provides a &#8220;Stopwatch&#8221; class with much of the same functionality, however I included this simple custom class instead for the sake of learning and clarity so you can see exactly how this is being achieved, and how the concepts progress onwards from the simpler examples above. Out of curiosity I tested the script using .Net&#8217;s Stopwatch class in place of my own, and happily it came out with near-identical results!</em>)</p>
<p>Without further ado, here&#8217;s the CodeProfiler class:</p>
<p><pre class="brush: csharp; light: true;">
using UnityEngine;
using System.Collections.Generic;

// Simple code profiler class for Unity projects
// @robotduck 2011
//
// usage: place on an empty gameobject in your scene
// then insert calls to CodeProfiler.Begin(id) and
// CodeProfiler.End(id) around the section you want to profile
//
// &quot;id&quot; should be string, unique to each code portion that you're timing
// for example, in your enemy update function, you might have:
//
//     function Update {
//         CodeProfiler.Begin(&quot;Enemy:Update&quot;);
//         &lt;the rest of your enemy update code here&gt;
//         CodeProfiler.End(&quot;Enemy:Update&quot;);
//     }
//
// the Begin id and the End id must match exactly.

public class CodeProfiler : MonoBehaviour
{
	float startTime = 0;
	float nextOutputTime = 5;
	int numFrames = 0;
	static Dictionary&lt;string, ProfilerRecording&gt; recordings = new Dictionary&lt;string, ProfilerRecording&gt;();
	string displayText;
	Rect displayRect = new Rect(10,10,460,300);
	
	void Awake() {
		startTime = Time.time;	
		displayText = &quot;\n\nTaking initial readings...&quot;;
	}
	
	void OnGUI() {
		GUI.Box(displayRect,&quot;Code Profiler&quot;);
		GUI.Label(displayRect, displayText);
	}
	
	public static void Begin(string id) {
		
		// create a new recording if not present in the list
		if (!recordings.ContainsKey(id)) {
			recordings[id] = new ProfilerRecording(id);
		}
				
		recordings[id].Start();
	}
	
	public static void End(string id) {
		recordings[id].Stop();
	}
	
	void Update() {
		
		numFrames++;
		
		if (Time.time &gt; nextOutputTime)
		{
			// time to display the results		
			
			
			// column width for text display
			int colWidth = 10;
			
			// the overall frame time and frames per second:
			displayText = &quot;\n\n&quot;;
			float totalMS = (Time.time-startTime)*1000;
			float avgMS = (totalMS/numFrames);
			float fps = (1000/(totalMS/numFrames));
			displayText += &quot;Avg frame time: &quot;;
			displayText += avgMS.ToString(&quot;0.#&quot;)+&quot;ms, &quot;;
			displayText += fps.ToString(&quot;0.#&quot;)+&quot; fps \n&quot;;

			// the column titles for the individual recordings:
			displayText += &quot;Total&quot;.PadRight(colWidth);
			displayText += &quot;MS/frame&quot;.PadRight(colWidth);
			displayText += &quot;Calls/fra&quot;.PadRight(colWidth);
			displayText += &quot;MS/call&quot;.PadRight(colWidth);
			displayText += &quot;Label&quot;;
			displayText += &quot;\n&quot;;
				
			// now we loop through each individual recording
			foreach(var entry in recordings)
			{
				// Each &quot;entry&quot; is a key-value pair where the string ID
				// is the key, and the recording instance is the value:
				ProfilerRecording recording = entry.Value;
				
				// calculate the statistics for this recording:
				float recordedMS = (recording.Seconds * 1000);
				float percent = (recordedMS*100) / totalMS;
				float msPerFrame = recordedMS / numFrames;
				float msPerCall = recordedMS / recording.Count;
				float timesPerFrame = recording.Count / (float)numFrames;
				
				// add the stats to the display text
				displayText += (percent.ToString(&quot;0.000&quot;)+&quot;%&quot;).PadRight(colWidth);
				displayText += (msPerFrame.ToString(&quot;0.000&quot;)+&quot;ms&quot;).PadRight(colWidth);
				displayText += (timesPerFrame.ToString(&quot;0.000&quot;)).PadRight(colWidth);
				displayText += (msPerCall.ToString(&quot;0.0000&quot;)+&quot;ms&quot;).PadRight(colWidth);
				displayText += (recording.id);
				displayText += &quot;\n&quot;;

				// and reset the recording
				recording.Reset();
			}
			Debug.Log(displayText);	
				
			// reset &amp; schedule the next time to display results:
			numFrames = 0;
			startTime = Time.time;
			nextOutputTime = Time.time + 5;
			
		}	
	}
}


// this is the ProfileRecording class which is simply included
// directly after the CodeProfiler class in the same file.
// The ProfileRecording class is basically for &quot;internal use
// only&quot; - you don't need to place it on a gameobject or interact
// with it in any way yourself, it's purely used by the
// CodeProfiler to do its job.

class ProfilerRecording
{
	// this class accumulates time for a single recording
	
	int count = 0;
	float startTime = 0;
	float accumulatedTime = 0;
	bool started = false;
	public string id;
	
	public ProfilerRecording(string id)
	{
		this.id = id;
	}
	
	public void Start() {
		if (started) { BalanceError(); }
		count++;
		started = true;
		startTime = Time.realtimeSinceStartup; // done last
	}
	
	public void Stop() {
		float endTime = Time.realtimeSinceStartup; // done first
		if (!started) { BalanceError(); }
		started = false;
		float elapsedTime = (endTime-startTime);
		accumulatedTime += elapsedTime;
	}
	
	public void Reset() {
		accumulatedTime = 0;
		count = 0;
		started = false;
	}
	
	void BalanceError() {
		// this lets you know if you've accidentally
		// used the begin/end functions out of order
		Debug.LogError(&quot;ProfilerRecording start/stops not balanced for '&quot;+id+&quot;'&quot;);	
	}
	
	public float Seconds {
		get { return accumulatedTime; }
	}
	
	public int Count {
		get { return count; }
	}

}

</pre></p>
<p>Of course this is a simple script and could be vastly improved on. It has significant shortcomings, and does not do a number of things which perhaps it should, such as:</p>
<p>- Sort the results into any particular order<br />
- Deduct the average time taken for an &#8220;empty reading&#8221;<br />
- Give similar results to Unity Pro&#8217;s profiler *<br />
- Graph the results.<br />
- Make you a much-needed cup of tea.</p>
<p>I&#8217;ll leave these as an excercise for the reader. May I recommend starting with the last item first.</p>
<p><em>* Unity&#8217;s profiler seems to assign larger times to function calls than those recorded by simply checking the time at the beginning and end of a function &#8211; I&#8217;m guessing this is because it includes other things such as the time taken for the Unity engine to actually invoke the function (which is done via Reflection for MonoBehaviour events like Update).</em></p>
<p>In part 3 of this series, I&#8217;ll be examining the performance of various common code structures and techniques in Unity and shedding light on some faster alternatives, as well as exposing the &#8220;voodoo&#8221; optimisation techniques that some of us use just-in-case, but which actually provide little or no benefit!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/395/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=395&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2011/08/05/code-optimization-in-unity-part-2/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>
	</item>
		<item>
		<title>Code Optimization in Unity : Part 1</title>
		<link>http://robotduck.wordpress.com/2011/07/26/code-optimization-in-unity-part-1/</link>
		<comments>http://robotduck.wordpress.com/2011/07/26/code-optimization-in-unity-part-1/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 08:30:36 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=354</guid>
		<description><![CDATA[&#8220;Code Optimization&#8221; : the pursuit of modifying code to work more efficiently. Optimizing code in general can be a controversial subject, and upon wading into the topic even ankle-deep, you are bound to encounter the well-known quote, &#8220;Premature optimization is the root of all evil&#8221;. It&#8217;s from a 1974 paper by Donald Knuth, in which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=354&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em><strong>&#8220;Code Optimization&#8221; : the pursuit of modifying code to work more efficiently.</strong></em></p>
<p>Optimizing code in general can be a controversial subject, and upon wading into the topic even ankle-deep, you are bound to encounter the well-known quote, &#8220;Premature optimization is the root of all evil&#8221;.</p>
<p>It&#8217;s from a <a href="http://www.google.com/search?q=Donald+Knuth+Structured+Programming+with+go+to+Statements" target="_blank">1974 paper by Donald Knuth</a>, in which he warns programmers against wasting &#8220;&#8230;enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs&#8221;. *</p>
<p>This is good advice, and experienced programmers understand it. However the advice is more problematic if you don&#8217;t have so much experience in programming, because your ability to even estimate which parts of your project might be &#8220;non-critical&#8221; are not yet well developed. This makes the advice rather unhelpful to those who perhaps need it most. So, this article is an attempt to shed some light on the subject, as well as being an introduction to some of my optimization tests that I have been putting together.</p>
<p>The specific goals of optimization in Unity tend to revolve around making your game run faster so that it plays at an acceptable rate. There are occasionally other goals, such as reducing memory usage, or even drawing less battery power, but as a starting point I will be focusing on optimizing for speed.</p>
<p>For a game to run at an acceptable speed, it needs to reach a certain acceptable number of &#8220;Frames Per Second&#8221;. Each frame, your game has to execute all the relevant code, calculate physics, play sounds, and display the graphics in their current state. Each of those tasks takes a certain amount of time to complete, and to achieve a speed of (say) 30 frames per second, the computer must calculate everything it needs to display the next frame of your game in one-thirtieth of a second. The relative time taken for each task can be thought of as its &#8220;cost&#8221;, and the total time available to you each frame, can be thought of as your &#8220;budget&#8221;.</p>
<p>Understanding and identifying the relative sizes of the costs in your project is a crucial first step. Without doing this, you are essentially working blind. Imagine trying to make a car go faster by adjusting the angle of its aerofoil, without noticing that there is a trailer full of rubble attached to the back. Or trying to balance your monthly food budget by selecting between the two cheapest brand of tea-bags, while at the same time forgetting to cancel your weekly delivery of caviare. The differences in scale within the operations in your game can be even larger than these examples.</p>
<p>I regularly see questions in Unity forums and chat rooms which ask about whether a certain function is faster than some other function, or whether one kind of loop or data structure is faster than another. These kind of comparisons <em>are</em> sometimes valid, and there is a place for looking for optimizations at that level of detail &#8211; however it&#8217;s vastly more important to first be able to understand whether these things are relevant at all in the overall view of what is taking up time within your game each frame.</p>
<p>The first thing you should know is that unless you&#8217;re doing something very unusual, your code is <em>probably not</em> taking up a large portion of that time. Back in 1974, and indeed in many modern day programs in the wider area of computer science, your own code would be the first place to look to speed things up, however things are very different when you&#8217;re working within a high-level games-focused environment like the Unity engine. For a typical Unity game &#8211; particularly a desktop or web game, there is usually an awful lot going on that isn&#8217;t connected to the speed of your own code at all. The rendering of the graphics and the physics engine calculations are likely to be taking up the majority of the time it takes for you game to complete a whole single &#8220;frame&#8221;.</p>
<p>I can give you a couple of examples using the profiler which comes with the Pro version of Unity:</p>
<p><a href="http://robotduck.files.wordpress.com/2011/07/jetgameprofiler.jpg"><img title="jetGameProfiler" src="http://robotduck.files.wordpress.com/2011/07/jetgameprofiler.jpg?w=450&#038;h=575" alt="" width="450" height="575" /></a></p>
<p>The above game is a kind of aerial combat game. Listed under the screenshot is the output from Unity&#8217;s profiler, showing the relative time taken for each of the listed functions running in the game. You can see the camera render function at the top of the list, taking 38% of the frame time. Next is physics engine taking up a similar sized portion of time &#8211; there are lots of objects flying around, mostly debris in the above pic. After that comes the GUI rendering (which is drawing the radars, target sight and the on-screen text), then Particle system code (unity&#8217;s built in code, not code I wrote), then &#8220;Overhead&#8221; which is pretty vague but I guess it&#8217;s just some underlying cost of Unity doing its stuff.</p>
<p>Finally we reach the first item in the list which contains <em>any code at all that I wrote myself</em>. The Jet&#8217;s FixedUpdate function, weighing in at 2.5% of the frame time.</p>
<p>This is the main script for the player&#8217;s jet in the game, but also this script is on about 6 other enemy jets in the game too, and even has the AI code in there. So that single entry is actually running all 7 jets in the game.</p>
<p>This isn&#8217;t a tiny script &#8211; the FixedUpdate function is about 500 lines long, dealing with applying forces to the jet object, targetting, firing, ammo, and also contains the AI code for the enemy jets!</p>
<p>Here&#8217;s another example:</p>
<p><a href="http://robotduck.files.wordpress.com/2011/07/hometowngpprofiler.jpg"><img class="alignnone size-full wp-image-362" title="hometownGpProfiler" src="http://robotduck.files.wordpress.com/2011/07/hometowngpprofiler.jpg?w=450&#038;h=650" alt="" width="450" height="650" /></a></p>
<p>At the top, you can see the RenderCubeMapReflection class is taking up a whopping 35% of the total frame time in the above game. Below that is the main camera&#8217;s rendering function, at 22%. TheRenderCubeMapReflection class is responsible for building a cubemap texture from 6 camera angles from the car&#8217;s position, which is then used as the reflection of the car in the game. The camera&#8217;s Render function then renders the single view from behind the car that we see in the screenshot.</p>
<p>If we also add on GUI.Repaint (which is used to draw the GUI), this comes to about 67% of the frame time just used for rendering graphics in this game. The physics comes in much lower in this game, because there is basically only a single moving object in the game. The two most expensive script functions &#8211; which are basically responsible for pretty much all the gameplay (Car.FixedUpdate at 12.5% and Car.Update at 8.9%) come to just over 20% combined.</p>
<p>And here&#8217;s an example of a simple racing game running on the iPhone (a 3GS model), using Unity&#8217;s iOS profiler output:</p>
<p><a href="http://robotduck.files.wordpress.com/2011/07/iphonestuntgame.jpg"><img class="alignnone size-full wp-image-378" title="iPhoneStuntGame" src="http://robotduck.files.wordpress.com/2011/07/iphonestuntgame.jpg?w=450&#038;h=300" alt="" width="450" height="300" /></a><br />
<pre class="brush: plain; light: true;">iPhone Unity internal profiler stats:
cpu-player&gt; min: 13.8   max: 32.4   avg: 20.1
frametime&gt; min: 28.2   max: 52.1   avg: 34.9
draw-call #&gt; min:  13    max:  17    avg:  14 | batched:    80
tris #&gt; min:  5096  max:  6932  avg:  6100 | batched:  5358
verts #&gt; min:  4052  max:  5798  avg:  4950 | batched:  2920
player-detail&gt;
physx:  8.4
batching:  1.2
render:  4.5
mono-scripts&gt; update:  2.3   fixedUpdate:  3.2 coroutines:  0.0</pre><br />
This is an unreleased prototype car racing game with 3 AI opponents, collectible items and physics objects strewn around the track. The profiler output is different, and most of the numbers (except those marked with #) are measured in milliseconds. I&#8217;ve cut out a few of the less relevant things, plus the items which came in at zero (such as skinned mesh animation &#8211; since this game doesn&#8217;t use it). My average frame time is 34.9ms (which works out at roughly 30fps), and of that time, my scripts (update &amp; fixedUpdate) take up about 15% of the total frame time, physics take 24%, and rendering takes about 12%. I&#8217;m assuming the remaining time is simply the overhead of the unity engine running on the iPhone.</p>
<p>So again we can see that although the time taken to execute my code does have some significance, it&#8217;s certainly not the dominant factor in determining how fast the game runs. I think from these three examples, the take-away message should be:</p>
<p><strong>Make sure you know whether you need to optimize your code at all.</strong></p>
<p>Compared to everything else going on in your game, it&#8217;s entirely possible that <em>all of your code</em> falls into the &#8220;non-critical&#8221; part that Knuth was referring to. If the first two games above were running slowly, and they needed to be optimized, it would not be sensible to start optimizing the code first, or perhaps even at all in the case of the jet game. There are clearly other things which are massively more important in terms of framerate &#8211; the number of particles, the draw distance, the number of draw calls, the image effects (particularly the car&#8217;s reflection!), the number and complexity of physics objects, etc.</p>
<p>As for the iPhone game above, there may be a case for optimizing the code, but only once the physics have been double checked to be as simple and efficient as they can possibly be &#8211; since they consume the most time per frame.</p>
<p>Now, somewhat ironically, I started writing this article as an introduction to the low-level optimization tests I have been putting together which test the relative speeds of various common structures and techniques used in unity game programming. However this whole thing may have accidentally ended up sounding more like a warning to avoid code optimization altogether! This is not what I&#8217;m saying, because code optimization does have its place &#8211; particularly when targeting iOS or Android devices. It&#8217;s just important to make sure that you have a good overview of where the processing time is really being spent in your game before diving into the code to try to make it faster, and I guess this article will act as a primer for that.</p>
<p>In my next post on the subject, I <em>will</em> be getting down to the nitty-gritty of code optimization in Unity,  including the results of my performance tests, and some examples of how you can measure the speed of your code yourself, even if you don&#8217;t have access to Unity Pro&#8217;s profiler &#8211; so stay tuned!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=354&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2011/07/26/code-optimization-in-unity-part-1/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2011/07/jetgameprofiler.jpg" medium="image">
			<media:title type="html">jetGameProfiler</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2011/07/hometowngpprofiler.jpg" medium="image">
			<media:title type="html">hometownGpProfiler</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2011/07/iphonestuntgame.jpg" medium="image">
			<media:title type="html">iPhoneStuntGame</media:title>
		</media:content>
	</item>
		<item>
		<title>Damage Control</title>
		<link>http://robotduck.wordpress.com/2011/02/03/damage-control/</link>
		<comments>http://robotduck.wordpress.com/2011/02/03/damage-control/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 10:16:38 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=332</guid>
		<description><![CDATA[Hello all, Just posting to announce a new game that I recently finished working on at Skive. It&#8217;s another Unity 3D game, called &#8220;Damage Control&#8220;. ,It&#8217;s a much smaller production than our previous Unity game, but hopefully offers some bite-sized lunchbreak-style fun! It&#8217;s an unusual action puzzle game in which you control a demolition wrecking [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=332&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello all,</p>
<p>Just posting to announce a new game that I recently finished working on at <a href="http://skive.co.uk" target="_blank">Skive</a>. It&#8217;s another Unity 3D game, called &#8220;<strong>Damage Control</strong>&#8220;. ,It&#8217;s a much smaller production than our <a title="Hometown GP : Launched!" href="http://robotduck.wordpress.com/2010/09/11/hometown-gp-launched/">previous Unity game</a>, but hopefully offers some bite-sized lunchbreak-style fun!</p>
<p>It&#8217;s an unusual action puzzle game in which you control a demolition wrecking ball with your mouse. You can swing the ball at the building to demolish any part you choose, however behind the front facade of the building are different coloured layers of brick.</p>
<p>The goal of the game is to match a &#8220;target pattern&#8221; (shown top-left) within a time-limit by knocking chunks out of the building front to reveal different coloured layers beneath.</p>
<p>Anyway, this video probably gives a better idea than my rambling!</p>
<span style="text-align:center; display: block;"><a href="http://robotduck.wordpress.com/2011/02/03/damage-control/"><img src="http://img.youtube.com/vi/0E-Ljz_3trg/2.jpg" alt="" /></a></span>
<p>The game was produced in a particularly short time-frame (25 days), and uses a Flash front-end for the interface, instructions and level-select screens.</p>
<p>You can play it at:</p>
<p><a href="http://kitkat.co.uk/Flash/#/need-a-break/games/damage-control" target="_blank">http://kitkat.co.uk/Flash/#/need-a-break/games/damage-control</a></p>
<p>And you can read more about how this Unity game tied in with the KitKat site here:</p>
<p><a href="http://blog.skive.co.uk/index.php/2010/08/24/kit-kat-music-brands-biggest-ever-digital-spend/">http://blog.skive.co.uk/index.php/2010/08/24/kit-kat-music-brands-biggest-ever-digital-spend/</a></p>
<div id="_mcePaste" class="mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;overflow:hidden;">http://www.youtube.com/watch?v=0E-Ljz_3trg</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/332/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=332&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2011/02/03/damage-control/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>
	</item>
		<item>
		<title>Hometown GP : Launched!</title>
		<link>http://robotduck.wordpress.com/2010/09/11/hometown-gp-launched/</link>
		<comments>http://robotduck.wordpress.com/2010/09/11/hometown-gp-launched/#comments</comments>
		<pubDate>Sat, 11 Sep 2010 18:33:59 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=282</guid>
		<description><![CDATA[I&#8217;m really pleased to announce that our new game, &#8220;Hometown GP&#8220;, has been launched! This is the latest browser based racing game from us at Skive, this one being a Formula 1 racer with a unique feature: By using a custom Google Maps interface, you can create your own tracks on real roads &#8211; pretty [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=282&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really pleased to announce that our new game, &#8220;<strong>Hometown GP</strong>&#8220;, has been launched!</p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/00.jpg"><img class="alignnone size-full wp-image-317" title="Hometown GP Screenshots" src="http://robotduck.files.wordpress.com/2010/09/00.jpg?w=450&#038;h=213" alt="Hometown GP Screenshots" width="450" height="213" /></a></p>
<p>This is the latest browser based racing game from us at <a href="http://skive.co.uk">Skive</a>, this one being a Formula 1 racer with a unique feature: By using a custom <strong>Google Maps</strong> interface, you can create your own tracks on real roads &#8211; pretty much anywhere in the world &#8211; and the game will dynamically generate a 3D racetrack which matches your route.</p>
<p>The idea is to be able to experience Formula 1 coming to your home town &#8211; so you could create a route which goes along your street, past your local shops or school, etc. Of course you can also choose to build anywhere else in the world too, if you feel like exploring! Combining Flash and Unity 3D technologies with route, altitude and satellite data from Google maps, this project breaks new ground when it comes to technology “Mash-Ups”.</p>
<p>If you&#8217;re logged in and finish 3 laps of your new track, it gets saved to the database and will show up as a marker pin along with everyone else&#8217;s tracks around the map of the world. You can share your tracks via facebook and twitter, and challenge your friends to beat your times on any course.</p>
<p>Here&#8217;s a video of the game in action:</p>
<span style="text-align:center; display: block;"><a href="http://robotduck.wordpress.com/2010/09/11/hometown-gp-launched/"><img src="http://img.youtube.com/vi/0WOX1Az5TlY/2.jpg" alt="" /></a></span>
<p>Notable features:</p>
<ul>
<li><strong>Intuitive custom track designer</strong> built on Google&#8217;s route finding technology.</li>
<li><strong>Dynamic 3D world</strong> created to match your design.</li>
<li><strong>Analysis of real satellite &amp; terrain data</strong> used to decide placement of trees, buildings and open space.</li>
<li><strong>Real altitude data</strong> used to create track height and surrounding hills.</li>
<li><strong>Realistic </strong>scales and Formula 1 speeds.</li>
<li><strong>Dynamic driving assistance</strong> adapts to your performance &#8211; casual gamers and skilled drivers alike should find the game equally enjoyable without the need to fiddle with menus and settings.</li>
<li><strong>Community features</strong> allow you to race other people&#8217;s tracks, and share your tracks with others.</li>
<li><strong>Adaptive quality degradation</strong> ensures very high visual quality on high-spec machines, while low-spec machines prioritise framerate &#8211; without the need for manual settings.</li>
</ul>
<p>You can play the the game here:</p>
<h2><a href="http://racing.vodafone.com/hometown">http://racing.vodafone.com/hometown</a></h2>
<p>However you might also like to try some of these direct links to tracks which I think show off the game quite well:<br />
(try and beat my times on these!)</p>
<ul>
<li> <a href="http://racing.vodafone.com/hometown/en-gb/?vfgpt=VkZHUF80NzA=">Bristol River Run (England)</a></li>
<li><a href="http://racing.vodafone.com/hometown/en-gb/?vfgpt=VkZHUF8yNTM=">The Serpentine (Hyde Park, London, England)</a></li>
<li><a href="http://racing.vodafone.com/hometown/en-gb/?vfgpt=VkZHUF8yNTM=">Presidio of San Francisco (California, USA)</a></li>
<li><a href="http://racing.vodafone.com/hometown/en-gb/?vfgpt=VkZHUF80Njc=">Happy Valley (Hong Kong, China)</a></li>
<li><a href="http://racing.vodafone.com/hometown/en-gb/?vfgpt=VkZHUF80Njc=">El Grado Dam (Spain)</a></li>
<li><a href="http://racing.vodafone.com/hometown/en-gb/?vfgpt=VkZHUF80Njc=">Banff: Tunnel Mountain (Alberta, Canada)</a></li>
<li><a href="http://racing.vodafone.com/hometown/en-gb/?vfgpt=VkZHUF80NjU=">Ct. Gilles Vielneuve: (Montreal, Canada)</a></li>
</ul>
<p>And finally, some stills &#8211; for those of you who like that kind of thing!</p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/49.jpg"><img class="alignnone size-full wp-image-288" title="Hometown GP Screenshot" src="http://robotduck.files.wordpress.com/2010/09/49.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/44.jpg"><img class="alignnone size-full wp-image-289" title="Hometown GP Screenshot" src="http://robotduck.files.wordpress.com/2010/09/44.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a><a href="http://robotduck.files.wordpress.com/2010/09/29.jpg"></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/29.jpg"><img class="alignnone size-full wp-image-290" title="Hometown GP Screenshot" src="http://robotduck.files.wordpress.com/2010/09/29.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/03.jpg"><img class="alignnone size-full wp-image-296" title="Hometown GP Screenshot" src="http://robotduck.files.wordpress.com/2010/09/03.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/06.jpg"><img class="alignnone size-full wp-image-294" title="Hometown GP Screenshot" src="http://robotduck.files.wordpress.com/2010/09/06.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/04.jpg"><img class="alignnone size-full wp-image-295" src="http://robotduck.files.wordpress.com/2010/09/04.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/20.jpg"><img class="alignnone size-full wp-image-291" title="Hometown GP Screenshot" src="http://robotduck.files.wordpress.com/2010/09/20.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/16.jpg"><img class="alignnone size-full wp-image-292" title="Hometown GP Screenshot" src="http://robotduck.files.wordpress.com/2010/09/16.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/09/15.jpg"><img class="alignnone size-full wp-image-293" title="Hometown GP Screenshot" src="http://robotduck.files.wordpress.com/2010/09/15.jpg?w=450&#038;h=213" alt="Hometown GP Screenshot" width="450" height="213" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/282/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=282&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2010/09/11/hometown-gp-launched/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/00.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshots</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/49.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/44.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/29.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/03.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/06.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/04.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/20.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/16.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/09/15.jpg" medium="image">
			<media:title type="html">Hometown GP Screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick Tip : How to choose which way to turn?</title>
		<link>http://robotduck.wordpress.com/2010/09/07/quick-tip-how-to-choose-which-way-to-turn/</link>
		<comments>http://robotduck.wordpress.com/2010/09/07/quick-tip-how-to-choose-which-way-to-turn/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 11:57:34 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Code and Scripting]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=270</guid>
		<description><![CDATA[Often situations arise in game coding &#8211; particularly in AI &#8211; where you need to be able to calculate which way to turn in order to reach a certain angle. Certain types of motion in Unity allow you to avoid this question altogether, such as Slerping (a.k.a. using spherical interpolation) from one rotation to another. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=270&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Often situations arise in game coding &#8211; particularly in AI &#8211; where you need to be able to calculate which way to turn in order to reach a certain angle.</p>
<p>Certain types of motion in Unity allow you to avoid this question altogether, such as <a href="http://unity3d.com/support/documentation/ScriptReference/Quaternion.Slerp.html">Slerping</a> (a.k.a. using spherical interpolation) from one rotation to another.  Sometimes you need to be more explicit in your code however, and in  these cases you often need to deal with and make decisions based on the  angles themselves.</p>
<p>Some situations involve completely free-moving objects that need to turn in any direction, such as a spaceship that can fly in any direction in 3d space. Other times, you have more constrained situations (eg, a boat, car, or any other object which is turning but constrained to some kind of surface) where you simply want to decide between a clockwise or anticlockwise direction when turning.</p>
<p>This tip tackles the latter of the two, where you need to make a decision about turning clockwise or anticlockwise based on arbitrary rotations or directions as input.</p>
<p>An example of this would be an AI controlled car, which might need to turn towards a target (another car, or the next waypoint, for example). You don&#8217;t want to use interpolation, because that would preclude realistic car physics. You wouldn&#8217;t want it making a 270 degree turn to reach a target that was 90 degrees to the left, but how to determine which way to turn?</p>
<p>These situations usually boil down to one of the following cases, where you need to find:</p>
<ol>
<li>the angle between two rotations,</li>
<li>the angle between a rotation and a target <em>position</em>,</li>
<li>the angle between a rotation and a target <em>direction</em>, or</li>
<li>the angle between two direction vectors</li>
</ol>
<p>The key to solving anyof the above lies in the fact that whichever case you have, you can convert it to the last case &#8211; where you simply have two directional vectors to compare &#8211; and from there you can use a few simple math functions to return the angle you want. Unity provides some very useful functions in its API which help along the way.</p>
<p>Starting at case 1, you have two rotations (which in Unity are represented by <a href="http://unity3d.com/support/documentation/ScriptReference/Quaternion.html">Quaternions</a>).</p>
<p>A rotation can be converted to a directional vector by multiplying the quaternion by the world-relative &#8220;forward&#8221; direction. Forward in Unity is represented by the positive direction along the Z axis (i.e. 0,0,1) and there is a handy alias to this value on the <a href="http://unity3d.com/support/documentation/ScriptReference/Vector3.html">Vector3</a> class called &#8220;<a href="http://unity3d.com/support/documentation/ScriptReference/Vector3-forward.html">.forward</a>&#8220;, so assuming &#8220;rotationA&#8221; and &#8220;rotationB&#8221; are our quaternions, we can get our two directional vectors like this:<br />
<pre class="brush: csharp; light: true;">// convert both rotations to direction vectors:
var forwardA = rotationA * Vector3.forward;
var forwardB = rotationB * Vector3.forward;</pre><br />
It&#8217;s also worth noting that in most cases in Unity, when you&#8217;re dealing with a rotation, it is very likely to have come from a GameObject with a transform. If this is the case, there&#8217;s an easier method of getting the forward vector, which is to use the built-in variable: <a href="http://unity3d.com/support/documentation/ScriptReference/Transform-forward.html">transform.forward</a> which directly gives you an object&#8217;s forward direction as a vector:<br />
<pre class="brush: csharp; light: true;">var forwardA = objectA.transform.forward;
var forwardB = objectB.transform.forward;</pre><br />
Now looking at case 2, where we have a rotation and a target position. Assuming we&#8217;re working with gameobjects, we can use the <strong>transform.forward</strong> of our object that is trying to turn towards the target (eg, the car) for the forward direction, and if this script is placed on the car itself, it&#8217;s as simple as this:<br />
<pre class="brush: csharp; light: true;">var forwardA = transform.forward;</pre><br />
To get the direction vector towards the target (case 3), we just need to subtract the target&#8217;s position from the car&#8217;s position, like this:<br />
<pre class="brush: csharp; light: true;">var forwardB = target.position - transform.position;</pre><br />
You should now have two directional vectors whose angles you want to compare to each other.</p>
<p>The final part of the puzzle lies in the fact that you want a <strong>signed </strong>angle (i.e. either a positive or negative angle). That is, you want to know more than just the numeric difference in angles, you want to know whether to turn clockwise or anticlockwise to get there. To get a signed angle doesn&#8217;t really make a lot of sense in 3D space, because the direction of rotation from one direction to another could be in <em>any </em>3d direction (not just in one of two &#8216;flat&#8217; clockwise/anticlockwise directions).</p>
<p>For this reason, it usually makes sense to compare your vectors on a certain chosen 2D plane, and ignore the 3rd axis. For example, in the case of cars you&#8217;d probably want to compare the &#8220;Top Down&#8221; directions as if on a map, ignoring the inclines of hills. This would be the X-Z plane in Unity.</p>
<p>To convert these vector directions to numeric angles in this way, you can use the Atan2 function, like this:<br />
<pre class="brush: csharp; light: true;">// get a numeric angle for each vector, on the X-Z plane (relative to world forward)
var angleA = Mathf.Atan2(forwardA.x, forwardA.z);
var angleB = Mathf.Atan2(forwardB.x, forwardB.z);</pre><br />
However, this function returns its result in <a href="http://en.wikipedia.org/wiki/Radian">radians</a>, which is just a different scale for measuring angles, and can be converted back to degrees very simply by multiplying the result by a built-in value called <a href="http://unity3d.com/support/documentation/ScriptReference/Mathf.Rad2Deg.html">Rad2Deg</a> in Unity which is provided for just this purpose, so to have the result in degrees, the above lines would end up looking like this:<br />
<pre class="brush: csharp; light: true;">// get a numeric angle for each vector, on the X-Z plane (relative to world forward)
var angleA = Mathf.Atan2(forwardA.x, forwardA.z) * Mathf.Rad2Deg;
var angleB = Mathf.Atan2(forwardB.x, forwardB.z) * Mathf.Rad2Deg;</pre><br />
And finally, Unity provides a simple function for getting the signed difference between two numeric angles in degrees (which is what we&#8217;ve been working towards!) called <a href="http://unity3d.com/support/documentation/ScriptReference/Mathf.DeltaAngle.html">DeltaAngle</a>, which you would use like this:<br />
<pre class="brush: csharp; light: true;">// get the signed difference in these angles
var angleDiff = Mathf.DeltaAngle( angleA, angleB );</pre><br />
You now have a single numeric value which should be in the range of -180 to 180. Negative values indicates your object should turn to its left, and positive, to its right.</p>
<p>Hope this comes in handy out there in Unityland!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/270/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/270/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/270/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=270&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2010/09/07/quick-tip-how-to-choose-which-way-to-turn/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>
	</item>
		<item>
		<title>Yard Invaders 2 : experimental prototype</title>
		<link>http://robotduck.wordpress.com/2010/09/02/yard-invaders-2-experimental-prototype/</link>
		<comments>http://robotduck.wordpress.com/2010/09/02/yard-invaders-2-experimental-prototype/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 14:17:50 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=264</guid>
		<description><![CDATA[Well, my &#8220;Procedural Racer&#8221; game has been taxiing for launch for quite a while now &#8211; as soon as it&#8217;s ready I will be posting here. In the meantime, here&#8217;s a video of an experimental gameplay prototype I put together, as a possible sequel to one of my very old 2D shockwave games called &#8220;Yard [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=264&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, my &#8220;Procedural Racer&#8221; game has been taxiing for launch for quite a while now &#8211; as soon as it&#8217;s ready I will be posting here. In the meantime, here&#8217;s a video of an experimental gameplay prototype I put together, as a possible sequel to one of my very old 2D shockwave games called &#8220;Yard Invaders&#8221;.</p>
<span style="text-align:center; display: block;"><a href="http://robotduck.wordpress.com/2010/09/02/yard-invaders-2-experimental-prototype/"><img src="http://img.youtube.com/vi/QvNhBGAtFjg/2.jpg" alt="" /></a></span>
<p>I tried out a number of new things while putting this together, including:</p>
<ul>
<li>Procedurally generated spherical terrain</li>
<li>Spherical gravity</li>
<li>Custom grass shader</li>
<li>Depth of field effects</li>
<li>Explosion effects (not detonator)</li>
<li>Intuitive  auto-targeting of enemies</li>
</ul>
<p>Whether this ever makes it to the status of a finished game remains subject to the mysterious tides of fate.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/264/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=264&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2010/09/02/yard-invaders-2-experimental-prototype/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>
	</item>
		<item>
		<title>Racing Game Sneak Peek</title>
		<link>http://robotduck.wordpress.com/2010/06/22/racing-game-sneak-peek/</link>
		<comments>http://robotduck.wordpress.com/2010/06/22/racing-game-sneak-peek/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 21:10:22 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=230</guid>
		<description><![CDATA[I&#8217;ve been very quiet over the last few months, because I&#8217;ve been working on our latest Unity game. It&#8217;s crunch time right now &#8211; the game is due to be released shortly &#8211; and I&#8217;m getting pretty excited about being able to show it off! I can&#8217;t give away too much yet, but I do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=230&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been very quiet over the last few months, because I&#8217;ve been working on our latest Unity game. It&#8217;s crunch time right now &#8211; the game is due to be released shortly &#8211; and I&#8217;m getting pretty excited about being able to show it off! I can&#8217;t give away too much yet, but I do have the all-clear to release a few development screen captures to whet your appetite!</p>
<p>What I can share:</p>
<p>- It&#8217;s a racing game<br />
- It features very fast cars<br />
- It has procedurally created tracks, meaning it has&#8230; INFINITE LEVELS!</p>
<p>Here&#8217;s some video. (The track building process has had gratuitous animation added for artistic effect):</p>
<span style="text-align:center; display: block;"><a href="http://robotduck.wordpress.com/2010/06/22/racing-game-sneak-peek/"><img src="http://img.youtube.com/vi/qU46elhVnY0/2.jpg" alt="" /></a></span>
<p>And here are a few stills of the procedural system with some explanations:</p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural1.jpg"><img class="size-full wp-image-232 alignnone" title="globalGP-procedural1" src="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural1.jpg?w=450&#038;h=247" alt="" width="450" height="247" /></a><br />
First a track surface mesh is build based on a 3d spline curve</p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural2.jpg"><img class="size-full wp-image-233 alignnone" title="globalGP-procedural2" src="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural2.jpg?w=450&#038;h=247" alt="" width="450" height="247" /></a><br />
Detail objects are added along the roadside</p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural4.jpg"><img class="alignnone size-full wp-image-235" title="globalGP-procedural4" src="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural4.jpg?w=450&#038;h=247" alt="Non-intersecting positions are calculated for larger scenery objects" width="450" height="247" /></a><br />
Non-intersecting locations are calculated for larger roadside scenery</p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural5.jpg"><img class="size-full wp-image-245 alignnone" title="globalGP-procedural5" src="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural5.jpg?w=450&#038;h=247" alt="" width="450" height="247" /></a><br />
A heightmap is computed which fits the spline, and objects are automatically grounded to it</p>
<p>And here are a few in-game shots of some of the possible track layouts:</p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot1.jpg"><img class="alignnone size-full wp-image-242" title="globalGPpreview-shot1" src="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot1.jpg?w=450&#038;h=190" alt="" width="450" height="190" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot2.jpg"><img class="alignnone size-full wp-image-241" title="globalGPpreview-shot2" src="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot2.jpg?w=450&#038;h=190" alt="" width="450" height="190" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot3.jpg"><img class="alignnone size-full wp-image-240" title="globalGPpreview-shot3" src="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot3.jpg?w=450&#038;h=190" alt="" width="450" height="190" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot5.jpg"><img class="alignnone size-full wp-image-239" title="globalGPpreview-shot5" src="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot5.jpg?w=450&#038;h=190" alt="" width="450" height="190" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot6.jpg"><img class="alignnone size-full wp-image-238" title="globalGPpreview-shot6" src="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot6.jpg?w=450&#038;h=190" alt="" width="450" height="190" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot7.jpg"><img class="alignnone size-full wp-image-237" title="globalGPpreview-shot7" src="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot7.jpg?w=450&#038;h=190" alt="" width="450" height="190" /></a></p>
<p><a href="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot8.jpg"><img class="alignnone size-full wp-image-236" title="globalGPpreview-shot8" src="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot8.jpg?w=450&#038;h=190" alt="" width="450" height="190" /></a></p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:142px;width:1px;height:1px;overflow:hidden;">First a track surface mesh is build based on a 3d spline curve</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/230/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=230&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2010/06/22/racing-game-sneak-peek/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural1.jpg" medium="image">
			<media:title type="html">globalGP-procedural1</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural2.jpg" medium="image">
			<media:title type="html">globalGP-procedural2</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural4.jpg" medium="image">
			<media:title type="html">globalGP-procedural4</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgp-procedural5.jpg" medium="image">
			<media:title type="html">globalGP-procedural5</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot1.jpg" medium="image">
			<media:title type="html">globalGPpreview-shot1</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot2.jpg" medium="image">
			<media:title type="html">globalGPpreview-shot2</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot3.jpg" medium="image">
			<media:title type="html">globalGPpreview-shot3</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot5.jpg" medium="image">
			<media:title type="html">globalGPpreview-shot5</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot6.jpg" medium="image">
			<media:title type="html">globalGPpreview-shot6</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot7.jpg" medium="image">
			<media:title type="html">globalGPpreview-shot7</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/06/globalgppreview-shot8.jpg" medium="image">
			<media:title type="html">globalGPpreview-shot8</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick Tip : Unity Particle System Nebula</title>
		<link>http://robotduck.wordpress.com/2010/01/27/quick-tip-particle-system-nebula/</link>
		<comments>http://robotduck.wordpress.com/2010/01/27/quick-tip-particle-system-nebula/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 22:03:22 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=208</guid>
		<description><![CDATA[Here&#8217;s a quick way to create a &#8220;nebula&#8221; effect without any code at all: Create a default particle system from the menu in Unity&#8217;s UI Delete just the &#8220;Particle Animator&#8221; component Check the &#8220;One Shot&#8221; option in the emitter settings Now you have a static set of particles. The min &#38; max emission controls how [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=208&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick way to create a &#8220;nebula&#8221; effect without any code at all:</p>
<ul>
<li> Create a default particle system from the menu in Unity&#8217;s UI</li>
<li> Delete just the &#8220;Particle Animator&#8221; component</li>
<li> Check the &#8220;One Shot&#8221; option in the emitter settings</li>
</ul>
<p>Now you have a static set of particles. The min &amp; max emission controls how many particles there are (you should probably set them both to the same value, unless you want a random value somewhere between the two). The default particle textures are already fairly suitable as they are have a fuzzy glow look. Try these values for a very quick nebula-like effect:</p>
<ul>
<li> Min size: 0.1</li>
<li> Max size: 0.7</li>
<li> Min &amp; Max emission : 200</li>
</ul>
<p>You might want to set one of the ellipsoid size dimensions smaller than the others, to give it a sort of oval shape instead of spherical. And of course you could  use some custom particle textures, colour variations, and adjust the size to fit your game.</p>
<p><a href="http://robotduck.files.wordpress.com/2010/01/nebulascene.jpg"><img class="alignnone size-full wp-image-213" title="nebulaScene" src="http://robotduck.files.wordpress.com/2010/01/nebulascene.jpg?w=450&#038;h=148" alt="" width="450" height="148" /></a></p>
<p>When I tried this, I found that having two particle systems in the same location worked really well, where the first particle system serves to show the larger blobby white areas, and the second particle system has the <strong>size</strong> values turned right down so that the particles are tiny specks, and the <strong>emission</strong> values turned right up (to 2000 or so).</p>
<div id="attachment_212" class="wp-caption alignnone" style="width: 460px"><a href="http://robotduck.files.wordpress.com/2010/01/nebulabetterscene.jpg"><img class="size-full wp-image-212" title="nebulaBetterScene" src="http://robotduck.files.wordpress.com/2010/01/nebulabetterscene.jpg?w=450&#038;h=148" alt="" width="450" height="148" /></a><p class="wp-caption-text">Using two particle systems</p></div>
<p>The settings for the first particle system are:</p>
<ul>
<li>Min Size: 0.3</li>
<li>Max Size: 3.5</li>
</ul>
<p>And for the second particle system:</p>
<ul>
<li>Min Size: 0.01</li>
<li>Max Size: 0.03</li>
</ul>
<p>And apply these settings to both systems:</p>
<ul>
<li>Emit: On</li>
<li>One Shot: On</li>
<li>Simulate in world space: off</li>
<li>Min Emission: 2000</li>
<li>Max Emission: 2000</li>
<li>Ellipsoid: X:8, Y:4, Z:8</li>
</ul>
<p>Then add the second system as a child of the first system (by dragging the 2nd onto the 1st in the hierarchy). Because they are not set to simulate in world space, you can then just rotate the parent particle system and the whole nebula will rotate including the tiny dots in the child particle system.</p>
<span style="text-align:center; display: block;"><a href="http://robotduck.wordpress.com/2010/01/27/quick-tip-particle-system-nebula/"><img src="http://img.youtube.com/vi/Pxiy8IrKKPY/2.jpg" alt="" /></a></span>
<p><em>(until I sort out proper hosting for my unity files on this blog, you&#8217;ll have to make do with pretty pictures and video!)</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=208&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2010/01/27/quick-tip-particle-system-nebula/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/01/nebulascene.jpg" medium="image">
			<media:title type="html">nebulaScene</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/01/nebulabetterscene.jpg" medium="image">
			<media:title type="html">nebulaBetterScene</media:title>
		</media:content>
	</item>
		<item>
		<title>Duck&#8217;s Quick Tips : Intro</title>
		<link>http://robotduck.wordpress.com/2010/01/22/ducks-quick-tips-intro/</link>
		<comments>http://robotduck.wordpress.com/2010/01/22/ducks-quick-tips-intro/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 13:25:24 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Quick Tips]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=188</guid>
		<description><![CDATA[While going about my daily business (mainly coding in Unity 3D), unless we&#8217;re going through some sort of crunch point at work, I often spend a little bit of time each day &#8220;sharpening my saw&#8220;. That is, doing something that&#8217;s not directly related to the current main job, but theoretically makes me better at doing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=188&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://robotduck.files.wordpress.com/2010/01/sawicon90x90.jpg"><img class="alignleft size-full wp-image-191" title="sawIcon90x90" src="http://robotduck.files.wordpress.com/2010/01/sawicon90x90.jpg?w=450" alt=""   /></a>While going about my daily business (mainly coding in Unity 3D), unless we&#8217;re going through some sort of crunch point at work, I often spend a little bit of time each day &#8220;<a href="http://www.codinghorror.com/blog/archives/001236.html">sharpening my saw</a>&#8220;. That is, doing something that&#8217;s not directly related to the current main job, but theoretically makes me better at doing my job.</p>
<p>Sometimes it&#8217;s looking into a section of the manual or API that I&#8217;m less familiar with. Sometimes it&#8217;s reading up on developments in the technologies that surround my field of work. Sometimes it&#8217;s helping out with a question or two on the Unity forums, or the IRC channel (which are both places that I go looking for help myself too, sometimes). This often results in &#8220;saw-sharpening&#8221; because my favourite type of questions are the ones where I <em>sort of</em> know the answer, but I have to quickly look up / test out that knowledge to confirm it. This has the effect of hardening what was vague knowledge of a particlar area into a small chunk of concrete experience, which effectively adds to the array of tools and know-how that I have at my disposal when approaching my own work.</p>
<p>In this new &#8220;Quick Tips&#8221; category, I&#8217;m going to be documenting these short &amp; sweet nuggets of information. In effect, this is a kind of excuse to get a bit more content posted here in the tiny amounts of spare time that I have. They won&#8217;t be full tutorials, they might not be useful to everyone, and they will almost certainly vary wildly between beginner and advanced levels &#8211; but if you&#8217;re interested in the occasional sharpening of your Unity blade, please feel free to <a title="Subscribe to this blog" href="http://robotduck.wordpress.com/feed/">subscribe</a> or <a title="Follow me on twitter" href="http://twitter.com/robotduck">follow</a>!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=188&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2010/01/22/ducks-quick-tips-intro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2010/01/sawicon90x90.jpg" medium="image">
			<media:title type="html">sawIcon90x90</media:title>
		</media:content>
	</item>
		<item>
		<title>Christmas! (2 of 2) &#8211; Have a Smashing One! : The Skive Unity 3D Christmas Demo</title>
		<link>http://robotduck.wordpress.com/2009/12/24/christmas-2-of-2-have-a-smashing-one-the-skive-unity-3d-christmas-demo/</link>
		<comments>http://robotduck.wordpress.com/2009/12/24/christmas-2-of-2-have-a-smashing-one-the-skive-unity-3d-christmas-demo/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 12:58:49 +0000</pubDate>
		<dc:creator>duck</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://robotduck.wordpress.com/?p=175</guid>
		<description><![CDATA[So here it is &#8211; delayed, but just in time. It&#8217;s my christmas Unity 3D demo. Let loose with a giant excavator amongst the snow and ice sculptures. Making full use of Unity&#8217;s physics engine, and some of the pro features such as refraction in the ice shader, full-screen glow and ambient occlusion (although these [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=175&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://robotduck.files.wordpress.com/2009/12/xmas09_90x90.jpg"><img class="alignleft size-full wp-image-177" title="xmas09_90x90" src="http://robotduck.files.wordpress.com/2009/12/xmas09_90x90.jpg?w=450" alt=""   /></a>So here it is &#8211; delayed, but just in time. It&#8217;s my christmas Unity 3D demo. Let loose with a giant excavator amongst the snow and ice sculptures.</p>
<p>Making full use of Unity&#8217;s physics engine, and some of the pro features such as refraction in the ice shader, full-screen glow and ambient occlusion (although these features are automatically deactivated if the frame rate drops too low).</p>
<p>The demo will fill your browser window, so if you find its running at too slow a frame rate, you can always reduce the size of the window. You can also manually flip up and down through the quality degradation steps, by holding down &#8216;Q&#8217; and pressing &#8217;1&#8242; or &#8217;2&#8242;.</p>
<p>Use arrow keys to control the scoop and exacator body, and use WSAD to control the tracks. Enjoy!</p>
<p><a href="http://skive.co.uk/xmas/"><img class="size-full wp-image-178 alignnone" title="xmas09a" src="http://robotduck.files.wordpress.com/2009/12/xmas09a.jpg?w=450" alt=""   /></a></p>
<p><a href="http://skive.co.uk/xmas/"><img class="alignnone size-full wp-image-179" title="xmas09b" src="http://robotduck.files.wordpress.com/2009/12/xmas09b.jpg?w=450" alt=""   /></a><br />
Mmm, refractive bump mapped ice!</p>
<p><a href="http://skive.co.uk/xmas/"><img class="alignnone size-full wp-image-180" title="xmas09c" src="http://robotduck.files.wordpress.com/2009/12/xmas09c.jpg?w=450" alt=""   /></a><br />
Time to get cracking!</p>
<p><a href="http://skive.co.uk/xmas/"><img class="alignnone size-full wp-image-182" title="xmas09e" src="http://robotduck.files.wordpress.com/2009/12/xmas09e.jpg?w=450" alt=""   /></a><br />
Once you manage to navigate your way to the ice block, it&#8217;s fairly easy to break</p>
<p><a href="http://skive.co.uk/xmas/"><img class="alignnone size-full wp-image-183" title="xmas09f" src="http://robotduck.files.wordpress.com/2009/12/xmas09f.jpg?w=450" alt=""   /></a><br />
My work here is done!</p>
<p><a href="http://skive.co.uk/xmas/"><img class="alignnone size-full wp-image-184" title="xmas09g" src="http://robotduck.files.wordpress.com/2009/12/xmas09g.jpg?w=450" alt=""   /></a><br />
Or is it?&#8230; destroy the rest!</p>
<h2></h2>
<h2><a title="The Skive Unity3D Christmas Demo" href="http://skive.co.uk/xmas/">The Skive Unity3D Christmas Demo &#8211; Click here to play!</a></h2>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robotduck.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robotduck.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robotduck.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robotduck.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robotduck.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robotduck.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robotduck.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robotduck.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robotduck.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robotduck.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robotduck.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robotduck.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robotduck.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robotduck.wordpress.com/175/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=robotduck.wordpress.com&amp;blog=6109516&amp;post=175&amp;subd=robotduck&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://robotduck.wordpress.com/2009/12/24/christmas-2-of-2-have-a-smashing-one-the-skive-unity-3d-christmas-demo/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f828fc4f9cdc1bc853783ca76f1397bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duck</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2009/12/xmas09_90x90.jpg" medium="image">
			<media:title type="html">xmas09_90x90</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2009/12/xmas09a.jpg" medium="image">
			<media:title type="html">xmas09a</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2009/12/xmas09b.jpg" medium="image">
			<media:title type="html">xmas09b</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2009/12/xmas09c.jpg" medium="image">
			<media:title type="html">xmas09c</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2009/12/xmas09e.jpg" medium="image">
			<media:title type="html">xmas09e</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2009/12/xmas09f.jpg" medium="image">
			<media:title type="html">xmas09f</media:title>
		</media:content>

		<media:content url="http://robotduck.files.wordpress.com/2009/12/xmas09g.jpg" medium="image">
			<media:title type="html">xmas09g</media:title>
		</media:content>
	</item>
	</channel>
</rss>
