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

<channel>
	<title>Silent Kraken &#187; Tools</title>
	<atom:link href="http://www.blog.silentkraken.com/tag/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.silentkraken.com</link>
	<description>Game development for real</description>
	<lastBuildDate>Tue, 22 Jun 2010 21:35:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Simple AudioManager code for your Unity3d project</title>
		<link>http://www.blog.silentkraken.com/2010/04/06/audiomanager/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.blog.silentkraken.com/2010/04/06/audiomanager/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 05:47:31 +0000</pubDate>
		<dc:creator>sethillgard</dc:creator>
				<category><![CDATA[Game development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Unity3d]]></category>

		<guid isPermaLink="false">http://www.blog.silentkraken.com/?p=161</guid>
		<description><![CDATA[This is a simple component class that I created to help you play sounds in Unity3d. <a href="http://www.blog.silentkraken.com/2010/04/06/audiomanager/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blog.silentkraken.com%2F2010%2F04%2F06%2Faudiomanager%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blog.silentkraken.com%2F2010%2F04%2F06%2Faudiomanager%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>You know, sometimes very simple code has to be written again and again by lots of different people to solve the same basic problem. I think playing audio is one of such cases in Unity3d.</p>
<p>You have the audio components: <a href="http://unity3d.com/support/documentation/Components/class-AudioSource.html">AudioSource </a>(attached to your sound emitter) and <a href="http://unity3d.com/support/documentation/Components/class-AudioListener.html">AudioListener </a>(attached to the main camera). Now, the problem is that audio clips are represented by the <a href="http://unity3d.com/support/documentation/Components/class-AudioClip.html">AudioClip </a>class, and each AudioSource can have a single AudioClip playing at the moment. That is sometimes ok, but other times, you want your game object to be able to play a number of different sounds, maybe at the same time (Think of a character playing footsteps sounds and maybe saying something at the same time).</p>
<p>Since it is very natural to have one manager object in your scene acting as a <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton</a>, I&#8217;ve written a component that can be attached to such manager. The work of this component is to play almost any sound you want to play in your game. The code is very simple and self explationary.</p>
<pre class="brush: csharp;">
// /////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Audio Manager.
//
// This code is release under the MIT licence. It is provided as-is and without any warranty.
//
// Developed by Daniel Rodríguez (Seth Illgard) in April 2010
// http://www.silentkraken.com
//
// /////////////////////////////////////////////////////////////////////////////////////////////////////////

using UnityEngine;
using System.Collections;

public class AudioManager : MonoBehaviour
{
    public AudioSource Play(AudioClip clip, Transform emitter)
    {
        return Play(clip, emitter, 1f, 1f);
    }

    public AudioSource Play(AudioClip clip, Transform emitter, float volume)
    {
        return Play(clip, emitter, volume, 1f);
    }

    /// &lt;summary&gt;
    /// Plays a sound by creating an empty game object with an AudioSource
    /// and attaching it to the given transform (so it moves with the transform). Destroys it after it finished playing.
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;clip&quot;&gt;&lt;/param&gt;
    /// &lt;param name=&quot;emitter&quot;&gt;&lt;/param&gt;
    /// &lt;param name=&quot;volume&quot;&gt;&lt;/param&gt;
    /// &lt;param name=&quot;pitch&quot;&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public AudioSource Play(AudioClip clip, Transform emitter, float volume, float pitch)
    {
        //Create an empty game object
        GameObject go = new GameObject (&quot;Audio: &quot; +  clip.name);
        go.transform.position = emitter.position;
        go.transform.parent = emitter;

        //Create the source
        AudioSource source = go.AddComponent&lt;AudioSource&gt;();
        source.clip = clip;
        source.volume = volume;
        source.pitch = pitch;
        source.Play ();
        Destroy (go, clip.length);
        return source;
    }

    public AudioSource Play(AudioClip clip, Vector3 point)
    {
        return Play(clip, point, 1f, 1f);
    }

    public AudioSource Play(AudioClip clip, Vector3 point, float volume)
    {
        return Play(clip, point, volume, 1f);
    }

    /// &lt;summary&gt;
    /// Plays a sound at the given point in space by creating an empty game object with an AudioSource
    /// in that place and destroys it after it finished playing.
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;clip&quot;&gt;&lt;/param&gt;
    /// &lt;param name=&quot;point&quot;&gt;&lt;/param&gt;
    /// &lt;param name=&quot;volume&quot;&gt;&lt;/param&gt;
    /// &lt;param name=&quot;pitch&quot;&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public AudioSource Play(AudioClip clip, Vector3 point, float volume, float pitch)
    {
        //Create an empty game object
        GameObject go = new GameObject(&quot;Audio: &quot; + clip.name);
        go.transform.position = point;

        //Create the source
        AudioSource source = go.AddComponent&lt;AudioSource&gt;();
        source.clip = clip;
        source.volume = volume;
        source.pitch = pitch;
        source.Play();
        Destroy(go, clip.length);
        return source;
    }
}
</pre>
<p>As you can see, this class is basically 6 overloads for the Play function. Basically we have two types: the type that takes a transform (emitter) as parameter and the type that takes a Vector3. The only difference is that if you provide a point (Vector3), the sound will be played there, but if you provide an emitter, the sound will be played where the emitter is, but will also follow the emitter as it moves (e.g. the engine of a passing car).<br />
Hope you find it useful!<br />
By the way, I&#8217;m planning on creating on tutorial on how to create Manager systems. By that I don&#8217;t mean simple components like this but rather the best way I have found to create such a Singleton object with those components, and how to integrate that with your game when you have multiple game states and game scenes (with potentially different managers). More on that soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.silentkraken.com/2010/04/06/audiomanager/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TransformUtilities</title>
		<link>http://www.blog.silentkraken.com/2010/02/06/transformutilities/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.blog.silentkraken.com/2010/02/06/transformutilities/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 03:36:02 +0000</pubDate>
		<dc:creator>sethillgard</dc:creator>
				<category><![CDATA[Game development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Unity3d]]></category>

		<guid isPermaLink="false">http://www.blog.silentkraken.com/?p=121</guid>
		<description><![CDATA[Release of the TransformUtilities tools for Unity3d. <a href="http://www.blog.silentkraken.com/2010/02/06/transformutilities/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.blog.silentkraken.com%2F2010%2F02%2F06%2Ftransformutilities%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.blog.silentkraken.com%2F2010%2F02%2F06%2Ftransformutilities%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<div id="attachment_149" class="wp-caption alignright" style="width: 269px"><a href="http://www.blog.silentkraken.com/wp-content/uploads/2010/02/TransformUtilitiesWindow.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-full wp-image-149 " title="TransformUtilitiesWindow" src="http://www.blog.silentkraken.com/wp-content/uploads/2010/02/TransformUtilitiesWindow.jpg" alt="" width="259" height="213" /></a><p class="wp-caption-text">This is how the tool looks like</p></div>
<p>Hello. I&#8217;ve been working on a set of four tools to aid in the Unity3d development. After using Unity for a while I encountered the classic problem of needing to copy the position of an object over and over. This led me to create the &#8220;Copy&#8221; tool. I&#8217;ve found a <a href="http://www.unifycommunity.com/wiki/index.php?title=CopyTransform">similar script</a> on the Unify community, but I wanted to extend the tool. It is now possible to copy position, rotation and scale of any axis you want. Also, the values apply to all objects selected in the scene.</p>
<p>After that, and inspired by the tools I found on the Gamebryo Lightspeed editor, I created the Randomize and Add Noise tools. Those tools work almost the same, the randomize the position, rotation of scale of any object selected (or all objects selected). The difference is that while Randomize sets the absolute values for position, rotation or scale, Add noise adds a delta to the current value of the transform. This is useful for example to randomize the Y rotation of all the trees in your level, or to make a bunch of boxes look more natural by not being perfectly aligned.</p>
<p>Finally, after been learning Autodesk 3ds Max, I created the Align tool inspired by a tool in that software. It basically takes a source transform, just like the Copy tool, then uses it&#8217;s collider and the collider of the object (or objects) selected to align it. You can align for example, the minimum point of your selection with the maximum point of your source (what you are aligning to) to place an object over another. It let&#8217;s you align using the minimum point, maximum point, the center of the object or the pivot point on both the selection and the source. You can align on all 3 axis.</p>
<p>To use these tool, all you need to do is download the script file, and add it into a folder named Editor in your project&#8217;s Asset folder. Once compiled by Unity you find the new functionality in Window -&gt; TransformUtilities, or simply press Ctrl+t (Cmd+t for Mac users)</p>
<p>Developed by Daniel Rodríguez (Seth Illgard) in January 2010</p>
<p><strong><a href="http://files.silentkraken.com/tools/unity3d/TransformUtilities/TransformUtilitiesWindow.cs">Download TransformUtilities!</a></strong></p>
<p>Hope you find them useful, and please let me know how can I improve theses tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.silentkraken.com/2010/02/06/transformutilities/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
