<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Rocket 5 Studios</title>
	
	<link>http://www.rocket5studios.com</link>
	<description>indie games for iPhone and iPad</description>
	<lastBuildDate>Wed, 01 Feb 2012 16:30:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/rocket5studios" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="rocket5studios" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">rocket5studios</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Make A 2D Game With Unity3D Using Only Free Tools: Beginning Enemy AI With A* Pathfinding</title>
		<link>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding/</link>
		<comments>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 16:48:03 +0000</pubDate>
		<dc:creator>Tim Miller</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.rocket5studios.com/?p=1266</guid>
		<description><![CDATA[In This installment of our 2D tutorial series, we will be adding enemy AI to our Lode Runner clone using A* Pathfinding. This post has been guest written by Adrian Seeto of Fun Mob Games who was also kind enough to write the AI scripts that are a huge part of bringing the game to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.rocket5studios.com/wp-content/uploads/2012/01/2dGamePt5_icon.png" alt="Make a 2d game in unity3d part 5" title="Make a 2d game in unity3d part 5" width="150" height="150" class="alignleft size-full wp-image-1267" />In This installment of our 2D tutorial series, we will be adding enemy AI to our Lode Runner clone using A* Pathfinding.  This post has been guest written by <a href="http://www.twitter.com/funmobgames" title ="FunMobGames on Twitter">Adrian Seeto</a> of <a href="http://FunMobGames.com" title="Visit FunMobGames.com">Fun Mob Games</a> who was also kind enough to write the AI scripts that are a huge part of bringing the game to life.</p>
<p>Adding the enemy AI required changes to many of the scripts that we added in the previous tutorials.  You can download the complete project <a href="http://www.rocket5studios.com/files/Rocket5_2DGame_part5.zip" title="Download Rocket5_2DGame_part5.zip">here</a> or you can follow the steps below to update your existing project.  I recommend following along with the tutorial as there&#8217;s tons of great information on implementing the AI with A*.  You can also play the game as it will be at the end of this tutorial <a href="http://www.rocket5studios.com/2dgametutorial/Rocket52DGamePart5.html" title="Playable version of our Lode Runner clone as it is at the end of Tutorial 5">here</a>.</p>
<h3>Installing the A* Package</h3>
<ol>
<li>Import the free version of <a href="http://www.arongranberg.com/unity/a-pathfinding/download/" title="Download the A* Pathfinding Project">Aron Granberg’s A* Pathfinding Project</a> into Unity3d</li>
<li>Create an empty GameObject and rename it <strong>A*</strong>. Make sure it&#8217;s positioned at <em>0,0,0</em></li>
<li>Drag the <em>/AstarPathfindingProject/Core/AstarPath.cs</em> file onto the <em>A*</em> GameObject</li>
<li>Click on the <em>A*</em> GameObject and disable the “<em>Allow Javascript</em>” option</li>
</ol>
<h3>Importing game C# scripts</h3>
<p>Many of the scripts have been modified since <a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-4/" title="Make A 2D Game With Unity3D Using Only Free Tools Part 4">Part 4</a> of this series, so you&#8217;ll need to update them.  If you&#8217;ve made changes to your own scripts then you&#8217;ll need to merge your changes into these new scripts.</p>
<ol>
<li>Copy these scripts into your <em>Assets/Scripts/</em> folder:</li>
<ol>
<li>Player.cs (updated)</li>
<li>PlayerAnims.cs (updated)</li>
<li>xa.cs (updated)</li>
<li>ChangeBehaviorGUI.cs (new)</li>
<li>Character.cs (new)</li>
<li>Enemy.cs (new)</li>
</ol>
<li>Copy this script into your <em>AstarPathfindingProject/Editor/GraphEditors</em> folder:</li>
<ol>
<li>MyGridGeneratorEditor.cs</li>
</ol>
<li>And finally copy this script into your <em>AstarPathfindingProject/Generators</em> folder:</li>
<ol>
<li>MyGridGraph.cs</li>
</ol>
</ol>
<h3>Configure The xa.cs Script</h3>
<p>Create a new Layer by going to <em>Edit &#8211;> Project Settings &#8211;> Tags</em> and then enter &#8220;<strong>Enemy</strong>&#8221; in one of the empty User Layer slots.</p>
<ol>
<li>Select the <em>Global/Scripts/xa</em> GameObject</li>
<li>Set <strong>Ground Mask</strong> field to “<strong>Ground</strong>”</li>
<li>Set <strong>Ladder</strong> and <strong>Rope Mask</strong> field to “<strong>NoDraw</strong>”</li>
<li>Set <strong>Enemy Mask</strong> field to “<strong>Enemy</strong>”</li>
</ol>
<h3>Miscellaneous Project Changes</h3>
<p>Note that some of these may be unnecessary or redundant depending on how your project is currently setup.</p>
<ol>
<li>Expand the <strong>Global</strong> game object in the Hierarchy and then select the &#8220;<strong>border bottom</strong>&#8221; and &#8220;<strong>border top</strong>&#8221; GameObjects and set their layer to <strong>Ground</strong>.  This is so enemies can stand on it if/when we dig a trap above the bottom border and our enemies fall into it they won’t fall continue through the border into the great abyss.</li>
<li>Select the <strong>player</strong> object in the Hierarchy and then change its Tag to “<strong>Player</strong>”</li>
<li>Select the <em>OT/View</em> object in the Hierarchy and uncheck &#8220;<strong>Always Pixel Perfect</strong>&#8220;. Note I&#8217;m not sure why Adrian turns off pixel perfect, feel free experiment on your own.</li>
</ol>
<h3>Configure A* Pathfinding For Our Level</h3>
<p>A* is a graph traversal algorithm widely used in computer science, and commonly used in games for path finding.  A full discussion of A* is beyond the scope of this tutorial, but there is some terminology you should be aware of.  A <em>graph</em> consists of <em>nodes</em> and the network of <em>connections</em> between them.  Once A* has been provided with a graph, you can query it to find the shortest path from one node to another.  A* will return a path way list of all the nodes that you must travel along to get from your start node to your end node, in the shortest path possible.  </p>
<p>More accurately, the path returned is the “least cost” path, because nodes have a specified penalty cost for traveling along it.  A* will attempt to create a path which incurs the least cost.  The unit of a penalty is up to the application developer.  For example, in an isometric RTS game the terrain tiles would be nodes, with 8 connections per node (except for the boundary tiles).  We could have the penalty cost units be related to the time it takes to travel on it.   A swampy area might therefore have very high penalties on the nodes in it, while the grass land nodes surrounding the swamp have smaller penalties.  A computer-controlled tank which wants to get from one side of the swamp to the other may then plot a course around the swamp if it costs less, even though it is physically further (i.e. more tiles must be travelled, but the total travel duration is less) . Of course, it is up to us as the game developer to implement all the code to actually slow the tank down if/when it travels over swamps, A* is only the pathfinder.</p>
<p>We don’t make use of penalties in this game because traveling along ropes, ladders, the ground, and falling is all done at the same speed.  If gravity in our game was a useful non-lethal force (i.e. falling is faster than climbing and just as safe) then we can set node penalties so that A* would return a path where jumping off a platform would be a preferable shortcut to climbing down the ladder. If your game enforces lethal falls from great heights, then you would need additional logic.</p>
<p>A game could have multiple graphs, for use by the various units (ships have different travel behavior to an infantry man for example).  For this tutorial, we only need to create one graph.  In the graph one node will be created for every tile in a 2d grid-like layout.  Each node may have up to 4 connections (up, down, left, right).  Aron’s A* Project includes several different path graph generators, such as GridGraph, ListGraph, and NavMeshGraph.  The GridGraph is a suitable starting point for our game.</p>
<p>The node connections generated by the base GridGraph are always bidirectional (if it creates a connection from from node1 to node2 then it will also create a connection from node2 to node1) which is not necessarily what we want.  Bidirectional paths are fine for ladders, ropes, and the ground because you can go up and down a ladder, and both left-to-right and right-to-left on rope and ground.  The problem arises when you want to include fall lanes. A fall lane is a term I’ve made up for a vertical one-way path that you can only travel on by falling.  Fall lanes exist under the ropes (you can let go of a rope and fall) and off of cliff edges (you can run off a cliff and fall down to a lower platform).  Once on a fall-lane you can’t travel in any direction but down until you’ve hit bottom.  This is a uni-directional connection so the nodes on a fall lane only have one connection each: a connection to the node directly below it.  Other nodes in the level will have between 2 and 4 connections each.  </p>
<p>We could use the base GridGraph and not bother about having any fall lanes, it would just mean that our AI would not plan any paths that involve letting go of ropes or running off platforms.  In this scenario you could still have your AI let go of ropes in a “reactionary” manner i.e. if it’s already on the rope and see a player below it, it could let go.  You would do this will “special case” code in your enemy AI loop.  However, its important to understand this is different from forward planning a route which takes into account the ability to jump off ropes.  In order to that kind of path planning with A*, you need to provide that information in the graph, via the fall lane concept.  </p>
<p>I’ve created a new generator class called “<em>MyGridGraph</em>” which inherits from GridGraph and overrides the Scan() and IsValidConnection() functions.  Our new MyGridGraph class implements the fall lanes idea so let’s add it the scene.</p>
<ol>
<li>Select the <strong>A*</strong> GameObject</li>
<li>Click the <em>Graphs -> Add Graph</em> button</li>
<ol>
<li>Add a new “<strong>My Grid Graph</strong>”</li>
<li><strong>Width</strong>: <em>26</em> (these dimensions match our level)</li>
<li><strong>Depth</strong>: <em>20</em></li>
<li><strong>Node Size</strong>: <em>1</em></li>
<li><strong>Aspect Ratio</strong>: <em>1</em></li>
<li><strong>Center</strong>: <em>0, 0.3, 0.01</em> (y is 0.3 so that our nodes are centered in the middle of each tile (which we already previously aligned at 0.3), the z is 0.01 because the integer coordinates used for Aron’s A* node positions have a fixed precision of 0.01 and anything smaller than that would cause troubles.)</li>
<li><strong>Rotation</strong>: <em>-90, 0, 0</em> (rotate x because our grid is for a side-on view rather than the expected top-down view)</li>
<li>Disable <strong>Cut Corners</strong> checkbox</li>
<li><strong>Connections</strong>: <em>Six</em> (we only need 4 connections per node up/down/left/right, but we don’t have that option)</li>
<li>Disable <strong>Collision testing</strong> checkbox</li>
<li>Disable <strong>Height testing</strong> checkbox</li>
<li><strong>Level Layers</strong>: <strong>Ground</strong> and <strong>NoDraw</strong></li>
<li>Scroll to the bottom and enable the <strong>Show Graphs</strong> checkbox then hit <strong>Scan</strong></li>
</ol>
</ol>
<p>If it worked right you should now see the A* graph layout in your game/scene window (enable Gizmos) similar to the following image (click to see a larger version). </p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2012/01/2dGamePt5_pathfinding.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2012/01/2dGamePt5_pathfinding_sm.png" alt="2dGamePt5 pathfinding" title="2dGamePt5 pathfinding" width="536" height="402" class="alignnone size-full wp-image-1280" /></a></p>
<p>The red squares represent nodes that the AI can <em>not</em> travel on.  All the bricks should have a red node centered on them.  Much of the black “air” tiles should also have a red square gizmo.  The tiles without the red gizmos are the nodes the AI can travel on.  The blue line represents the connections between nodes. You should therefore see that the AI can travel along the surface of ground tiles, along ropes, and up and down ladders.  You should also see the vertical fall lanes under ropes and over the edge of a platform.  If you are very perceptive you will see that the blue lines come in 2 thicknesses.  A thick line means that the connection is bidirectional (the line gizmo was rendered twice, once each way, making it thicker).  A thin line represents a unidirectional connection.</p>
<h3>Making Enemies</h3>
<p>Our enemies and the player classes both derive from the Character class which implements the movement code.  In this way we can ensure that the enemies and player move with the same constraints to help prevent giving either an unfair advantage, and just general time-saving and efficiency.  The character class does have a movement speed variable, so we can give the enemies different movement speeds than the player, if desired.</p>
<p>Below we create 2 enemy game objects.  I’ve just reused the player sprite for them, and I’ve given each one a different tint so I can tell them apart (helpful during the development stage). If you create your own different enemy sprite go ahead and use it.</p>
<ol>
<li>Create an empty GameObject called <strong>Enemies</strong> to use as an organizational holder.</li>
<li>Clone the <strong>player</strong> GameObject in the hierarchy and rename it to <em>enemy-1</em>.</li>
<li>Drag the <strong>enemy-1</strong> to child it under your <strong>Enemies</strong> GameObject.</li>
<li>Drag the <em>/AstarPathfindingProject/Core/Seeker.cs</em> script onto your <strong>enemy-1</strong>.  The script’s defaults are fine.  Go ahead and break enemy-1’s connection to the player prefab when prompted.  The Seeker provides the enemy with the ability to use A* path finding.  It has gizmos which paint green lines representing the found path.</li>
<li>Expand the <strong>enemy-1</strong> GameObject to see it’s children.</li>
<li>Delete the “<strong>shoot parent</strong>” child.</li>
<li>Add an empty GameObject child under <strong>enemy-1</strong> named “<strong>path target</strong>”.  Local Position 0,0,0 Local Scale 1,1,1. This will be a transform that the enemy script will move around to place on the desired target for our path finding AI.  Useful during debugging to see what it is targeting.</li>
<li>Duplicate “<strong>path target</strong>” and rename to “<strong>tile bounds</strong>”.  Add a box collider to it, set to <strong>Trigger</strong> and centered at <em>0,0,1</em> and scale <em>1,1,1</em>.  This is so that when we trap an enemy we can walk smoothly on top of it’s head as if it was ground.</li>
<li>Select the <em>enemy-1</em> game object and set its <strong>Layer</strong> to <strong>Enemy</strong> and apply to children.  Set its <strong>Tag</strong> to <strong>Enemy</strong> (leave children untagged).</li>
<li>Expand the enemy-1 Player script component.  Drag the <em>/Scripts/Enemy.cs</em> script onto the <strong>Player Script</strong> field to replace it with the Enemy script.</li>
<li>The Enemy script has 3 slots that need to be filled: <strong>Player</strong> and <strong>Player Tr</strong> (drag the player gameobject to those slots), and <strong>Target</strong> (drag the path target gameobject to this slot).</li>
<li>Expand the <strong>enemy-1 OTAnimatingSprite</strong> script.  Set the <strong>Material Reference</strong> slot to “<strong>tint</strong>”.  Set the <strong>Tint Color</strong> to <em>red</em> (or your preference) to visually differentiate it from the player.</li>
<li>Clone <strong>enemy-1</strong> as <strong>enemy-2</strong> and give it a green tint. (You may have to redo the Red tint on the other enemy due to an OT quirk).</li>
<li>Drag the enemies to suitable spawn points in the scene.</li>
<li>Optional: Select the <strong>Enemies</strong> root GameObject.  Drag the <em>ChangeBehaviors.cs</em> script onto it.  Set the Enemies array size to 2, and drag enemy-1 and enemy-2 into the slots.  This script will allow you to modify an enemy’s behavior on-the-fly via GUI between a “plain A* to Player” and a “Lode Runner-esque” behavior.  The A* to Player behavior simply follows the shortest path toward the player’s exact position.  The Lode Runner-esque behavior still uses A* but also tries to reimplement some of the reactionary quirks of the original game, especially with regards to ladder use.  See the Enemy.cs file for details.  You can disable/remove the ChangeBehaviors.cs script when you are done testing it out.</li>
</ol>
<h3>Conclusion</h3>
<p>While the enemy AI is not a completely faithful recreation of the original, it is hoped that it will provide you with enough of an idea on how you can use and implement A* path finding in your own creations.  </p>
<p>The AI scripts and this tutorial were contributed by Adrian Seeto of Fun Mob Games, creators of <a href="http://itunes.apple.com/app/pocket-bmx/id432832444?mt=8&#038;uo=4" title="Pocket BMX on the App Store">Pocket BMX</a> game for iOS, a free-roaming 2D bike tricking game with physics.  You can check them out at <a href="http://FunMobGames.com" title="Visit FunMobGames.com">FunMobGames.com</a> or on twitter <a href="http://www.twitter.com/funmobgames" title ="FunMobGames on Twitter">@FunMobGames</a>.</p>
<p>If you have any questions about the tutorial, please let us know in the comments below. Your support helps to keep these tutorial coming so be sure to follow us on <a href="http://www.twitter.com/rocket5studios" title="Rocket 5 Studios on Twitter">Twitter</a> and <a href="http://www.facebook.com/rocket5studios" title="Rocket 5 Studios on Facebook">Facebook</a>. This blog post is part of <a href="http://idevblogaday.com/" title="Visit iDevBlogADay">iDevBlogADay</a>, a collection of indie developers writing about their development experiences.</p>
<h3>More Tutorials In This Series</h3>
<p><a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-in-unity3d-using-only-free-tools-part-1/" title="Make A 2D Game in Unity3D Using Only Free Tools Part 1">Make A 2D Game in Unity3D Using Only Free Tools Part 1</a><br />
<a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/" title="Make A 2D Game with Unity3D Using Only Free Tools Part 2">Make A 2D Game with Unity3D Using Only Free Tools Part 2</a><br />
<a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-3/" title="Make A 2D Game With Unity3D Using Only Free Tools Part 3">Make A 2D Game With Unity3D Using Only Free Tools Part 3</a><br />
<a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-4/" title="Make A 2D Game With Unity3D Using Only Free Tools Part 4">Make A 2D Game With Unity3D Using Only Free Tools Part 4</a></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;count=horizontal&amp;text=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%3A%20Beginning%20Enemy%20AI%20With%20A%2A%20Pathfinding" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;count=horizontal&amp;text=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%3A%20Beginning%20Enemy%20AI%20With%20A%2A%20Pathfinding" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding%2F&amp;title=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%3A%20Beginning%20Enemy%20AI%20With%20A%2A%20Pathfinding" id="wpa2a_2"><img src="http://www.rocket5studios.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-beginning-enemy-ai-with-a-pathfinding/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rocket 5′s Unity3D “Flash in a Flash” Contest Entry: Jet-Skate Jo-Jo</title>
		<link>http://www.rocket5studios.com/game-jams/rocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo/</link>
		<comments>http://www.rocket5studios.com/game-jams/rocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 00:22:49 +0000</pubDate>
		<dc:creator>Tim Miller</dc:creator>
				<category><![CDATA[Dev Diary]]></category>
		<category><![CDATA[Game Jams]]></category>
		<category><![CDATA[Unity3D]]></category>

		<guid isPermaLink="false">http://www.rocket5studios.com/?p=1241</guid>
		<description><![CDATA[Hi everyone, this is just a quick update to tell you about our new circus themed web game called &#8220;Jet-Skate Jo-Jo&#8221; which you can play right here on our website. The game came about because over the holidays, Unity3D hosted a game creation contest titled &#8220;Flash in a Flash&#8221; where developers could submit a Flash [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.rocket5studios.com/wp-content/uploads/2012/01/Jet-Skate-Monkey-Logo_150.png" alt="Jet-Skate Jo-Jo logo" title="Jet-Skate Jo-Jo logo" width="150" height="144" class="alignleft size-full wp-image-1252" />Hi everyone, this is just a quick update to tell you about our new circus themed web game called &#8220;Jet-Skate Jo-Jo&#8221; which you can <a href="http://www.rocket5studios.com/jetskatejojo/" title="Play Jet-Skate Jo-Jo">play right here on our website</a>.  </p>
<p>The game came about because over the holidays, Unity3D hosted a game creation contest titled &#8220;Flash in a Flash&#8221; where developers could submit a Flash game using the new Flash exporter in the <a href="http://unity3d.com/unity/preview/" title="Unity3D 3.5 Developer Preview">Unity3D 3.5 Developer Preview</a>.  With a $20k first prize and a bunch of really good 2nd and 3rd place prizes, Cathy and I decided to dive head first into the competition.  </p>
<p>For our submission we wanted to make a new game from scratch that would take advantage of as many of the great features that Unity3D brings to Flash web game publishing as possible like physics, real time lighting and of course a 3D character and environment.  Since the schedule was super tight, we knew we had to make a game that was small enough to finish in a short amount of time while still being visually impressive and fun. The contest time ran from December 22nd and ended on January 5th which of course conflicted with all kinds of holiday plans. In the end were able to spend about 9 days working on the game.  We submitted the game at 2:30 AM Eastern time on January 5th which gave us about 30 minutes of padding before the contest submission deadline!  We ended up having to cut a few things from the game like sound, high scores and there are a few little bugs that I wish we could have fixed, but overall we made a really great little game in a super short amount of time that we&#8217;re all really happy with.</p>
<p>A quick shout out to our team: Cathy Feraday Miller did all of the character animations, designed the logo and contributed to much of the game design.  <a href="http://twitter.com/bakewell_cherry" title="Paul Capon on Twitter">Paul Capon</a> did all of the level and prop modeling and texturing, monkey textures and the skate model.  David Huynh rigged and weighted the monkey character which was originally modeled and rigged by Shaun Budhram and Roger Liu.  Tim Miller did the programming, game and level design and the UI design and art.</p>
<p><img src="http://www.rocket5studios.com/wp-content/uploads/2012/01/jetskatejojo_ss3_sm2.png" alt="Jet-Skate Jo-Jo Screenshot" title="Jet-Skate Jo-Jo Screenshot" width="536" height="402" class="alignnone size-full wp-image-1253" /></p>
<p><img src="http://www.rocket5studios.com/wp-content/uploads/2012/01/jetskatejojo_ss1_sm2.png" alt="Jet-Skate Jo-Jo Screenshot" title="Jet-Skate Jo-Jo Screenshot" width="536" height="402" class="alignnone size-full wp-image-1256" /></p>
<p><img src="http://www.rocket5studios.com/wp-content/uploads/2012/01/jetskatejojo_ss2_sm2.png" alt="Jet-Skate Jo-Jo Screenshot" title="Jet-Skate Jo-Jo Screenshot" width="536" height="402" class="alignnone size-full wp-image-1257" /></p>
<p><a href="http://www.rocket5studios.com/jetskatejojo/" title="Play Jet-Skate Jo-Jo">Play Jet-Skate Jo-Jo here</a> and be sure to let us know what you think of the game in the comments. And as always be sure to follow us on <a href="http://www.facebook.com/rocket5studios/" title="Rocket 5 Studios on Facebook">Facebook</a> and <a href="http://www.twitter.com/rocket5studios/" title="Rocket 5 Studios on Twitter">Twitter</a> to keep up to date on all the latest news from Rocket 5.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;count=horizontal&amp;text=Rocket%205%26%238242%3Bs%20Unity3D%20%26%238220%3BFlash%20in%20a%20Flash%26%238221%3B%20Contest%20Entry%3A%20Jet-Skate%20Jo-Jo" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;count=horizontal&amp;text=Rocket%205%26%238242%3Bs%20Unity3D%20%26%238220%3BFlash%20in%20a%20Flash%26%238221%3B%20Contest%20Entry%3A%20Jet-Skate%20Jo-Jo" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Frocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo%2F&amp;title=Rocket%205%26%238242%3Bs%20Unity3D%20%26%238220%3BFlash%20in%20a%20Flash%26%238221%3B%20Contest%20Entry%3A%20Jet-Skate%20Jo-Jo" id="wpa2a_4"><img src="http://www.rocket5studios.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.rocket5studios.com/game-jams/rocket-5s-unity3d-flash-in-a-flash-contest-entry-jet-skate-jo-jo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy Holidays</title>
		<link>http://www.rocket5studios.com/dev-diary/happy-holidays/</link>
		<comments>http://www.rocket5studios.com/dev-diary/happy-holidays/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 18:21:30 +0000</pubDate>
		<dc:creator>Tim Miller</dc:creator>
				<category><![CDATA[Dev Diary]]></category>

		<guid isPermaLink="false">http://www.rocket5studios.com/?p=1192</guid>
		<description><![CDATA[Happy holidays, everyone and here&#8217;s looking forward to a great 2012! Thank you to all of our friends and partners for making 2011 such a great year! If you haven&#8217;t had a chance to play our holiday themed web game yet, be sure to check it out! Click to play A Very Angry Christmas! Sincerely, [...]]]></description>
			<content:encoded><![CDATA[<p>Happy holidays, everyone and here&#8217;s looking forward to a great 2012! Thank you to all of our friends and partners for making 2011 such a great year!  </p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/12/Rocket5_holiday_card_2011.jpg"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/12/Rocket5_holiday_card_2011.jpg" alt="Rocket 5 holiday card 2011" title="Rocket 5 holiday card 2011" width="536" height="392" class="alignnone size-full wp-image-1193" /></a></p>
<p>If you haven&#8217;t had a chance to play our holiday themed web game yet, be sure to check it out!  Click to play <a href="http://www.rocket5studios.com/angryxmas" target="_blank" title="Play A Very Angry Christmas">A Very Angry Christmas!</a></p>
<p>Sincerely,<br />
Tim and Cathy and Rocket</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;count=horizontal&amp;text=Happy%20Holidays" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;count=horizontal&amp;text=Happy%20Holidays" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fhappy-holidays%2F&amp;title=Happy%20Holidays" id="wpa2a_6"><img src="http://www.rocket5studios.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.rocket5studios.com/dev-diary/happy-holidays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Christmas Carnage, Game Jam Style!</title>
		<link>http://www.rocket5studios.com/game-jams/christmas-carnage-game-jam-style/</link>
		<comments>http://www.rocket5studios.com/game-jams/christmas-carnage-game-jam-style/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 03:57:13 +0000</pubDate>
		<dc:creator>Tim Miller</dc:creator>
				<category><![CDATA[Dev Diary]]></category>
		<category><![CDATA[Game Jams]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.rocket5studios.com/?p=1171</guid>
		<description><![CDATA[This past weekend we took part in the 10th installment of the Game Prototype Challenge, a monthly game jam billed as &#8220;a spur of the moment motivator for making games&#8221;. Not that we need any motivation since we&#8217;re always working on games here. But what we like about jams is that they get us to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.rocket5studios.com/wp-content/uploads/2011/12/angry_christmas_icon.png" alt="" title="A Very Angry Christmas Icon" width="150" height="150" class="alignleft size-full wp-image-1173" />This past weekend we took part in the 10th installment of the <a href="http://gameprototypechallenge.com/" title="Game Prototype Challenge">Game Prototype Challenge</a>, a monthly game jam billed as &#8220;a spur of the moment motivator for making games&#8221;. Not that we need any motivation since we&#8217;re always working on games here.  But what we like about jams is that they get us to think about games differently since they usually involve including some kind of theme (&#8220;dreams&#8221; and &#8220;collectibles&#8221; for this jam) and they always have a very short deadline which gets us to try new things quickly without worrying about making the code necessarily clean or efficient.</p>
<p>Rocket 5 participated in GPC v.2 earlier this year with our game <a href="http://www.rocket5studios.com/snowball-jones/snowball-jones-and-the-game-prototype-challenge/" title="Snowball Jones Blog Post">Snowball Jones</a> <a href="http://www.rocket5studios.com/snowballjones/" title="Play Snowball Jones and the Last Crusade">And The Last Crusade</a>, which I co-developed with Kevin Feraday.</p>
<p>This time around our Art Director (AKA my wife Cathy) and I took a stab at the challenge with a holiday themed, tongue-in-cheek spoof of the wildly popular game Angry Birds.  In our game, titled A Very Angry Christmas, you control the hero from our upcoming game XS Force as he steps up to defend our hungry friends the pigs from those incessant birds.  For us the game actually serves two purposes:  for the Prototype Challenge, and as an interactive holiday card that we&#8217;ll send around to all our friends and business partners.</p>
<p><a href="http://www.rocket5studios.com/angryxmas/" title="Play A Very Angry Christmas" target="_blank"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/12/A_Very_Angry_Christmas_title_screen.png" alt="A Very Angry Christmas" title="Play A Very Angry Christmas" width="536" height="357" class="alignnone size-full wp-image-1176" /></a></p>
<p>This was Cathy&#8217;s first time participating in a game jam and this was my third time.  We used Unity3D to make the game and we used pre-existing gameplay code from XS Force for the player controls.  We revised the input from touch screen to keyboard and mouse so that the game could be played in a web browser (and it works great on the iPhone too, using our existing touch controls).  I also relied on several excellent Unity plugins including:  <a href="http://itween.pixelplacement.com/index.php" title="iTween">iTween</a> for various text and effect animations, <a href="http://www.unikronsoftware.com/2dtoolkit/" title="2D Toolkit">2D Toolkit</a> for the animated sprites and <a href="http://ragespline.com/" title="RageSpline">RageSpline</a> for the level background, which, next to iTween, is easily the best Unity plugin I&#8217;ve ever used.  Cathy did all of the character art and animations in Flash which were exported as .png&#8217;s and then added as sprites to Unity using 2D Toolkit.</p>
<p>If you happen to live in the Toronto area, you can play our games at the <a href="https://www.facebook.com/events/119775714803718/" title="More info on Facebook">#GPC Arcade: Year-One Roundup</a> presented by the <a href="https://www.facebook.com/groups/205500202826431/" title="Toronto Skillswap on Facebook">Toronto Skillswap</a> community at George Brown College on Friday December 16th. And if you&#8217;re not going to be there, you can <a href="http://www.rocket5studios.com/angryxmas/" title="Play A Very Angry Christmas" target="_blank">play A Very Angry Christmas right here on our website</a>!</p>
<p>Thanks for stopping by and please let us know in the comments if you have any thoughts on the game, and especially if you find any bugs <img src='http://www.rocket5studios.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . This blog post is part of <a href="http://idevblogaday.com/" title="iDevBlogADay">iDevBlogADay</a>, a collection of indie developers writing about their development experiences.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;count=horizontal&amp;text=Christmas%20Carnage%2C%20Game%20Jam%20Style%21" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;count=horizontal&amp;text=Christmas%20Carnage%2C%20Game%20Jam%20Style%21" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rocket5studios.com%2Fgame-jams%2Fchristmas-carnage-game-jam-style%2F&amp;title=Christmas%20Carnage%2C%20Game%20Jam%20Style%21" id="wpa2a_8"><img src="http://www.rocket5studios.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.rocket5studios.com/game-jams/christmas-carnage-game-jam-style/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>XS Force Art and Level Progress</title>
		<link>http://www.rocket5studios.com/dev-diary/xs-force-art-and-level-progress/</link>
		<comments>http://www.rocket5studios.com/dev-diary/xs-force-art-and-level-progress/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 05:10:24 +0000</pubDate>
		<dc:creator>Tim Miller</dc:creator>
				<category><![CDATA[Dev Diary]]></category>
		<category><![CDATA[XS FORCE]]></category>
		<category><![CDATA[iDevBlogADay]]></category>
		<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://www.rocket5studios.com/?p=1143</guid>
		<description><![CDATA[I&#8217;m taking a break this week from writing tutorials to show a bit of early XS Force level art. I say early because we&#8217;re still tuning the look &#8211; we&#8217;re heading for something that&#8217;s more stylized, less angular &#8211; but I thought it would be cool to show what we have at this point since [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m taking a break this week from writing tutorials to show a bit of early XS Force level art.  I say <em>early</em> because we&#8217;re still tuning the look &#8211; we&#8217;re heading for something that&#8217;s more stylized, less angular &#8211; but I thought it would be cool to show what we have at this point since it has been a while since we posted an XS Force development update.</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/11/XS_Force-early-look-lg.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/11/XS_Force-early-look-sm.png" alt="" title="XS_Force early look" width="536" height="486" class="alignnone size-full wp-image-1145" /></a></p>
<p>A few days ago I started looking for a new way to build the game&#8217;s levels in Unity.  I had been building levels from individual sprite tiles, each with their own collision that I made using <a href="http://www.unikronsoftware.com/2dtoolkit/" title="2D Toolkit">2D Toolkit</a>&#8216;s polygon collision editor.  This actually works pretty well for building 2d sprite-based levels, but I wanted to be able to create more freeform/organic levels.  </p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/11/XS_Force-sprite-lg.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/11/XS_Force-sprite-sm.png" alt="" title="XS_Force-sprite-sm" width="536" height="479" class="alignnone size-full wp-image-1152" /></a></p>
<p>A quick search of the Unity Asset Store revealed a plugin called <a href="http://ragespline.com/" title="RageSpline">RageSpline</a>.  Turns out that RageSpline is great for quickly building vector graphics right inside Unity and also makes it easy to add face accurate collisions to the objects so you can lay down level art and collision at the same time.</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/11/XS_Force-ragespline-lg.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/11/XS_Force-ragespline-sm.png" alt="" title="XS_Force-ragespline-sm" width="536" height="474" class="alignnone size-full wp-image-1156" /></a></p>
<p>That&#8217;s all for now.  This blog post is part of <a href="http://idevblogaday.com/" title="iDevBlogADay">iDevBlogADay</a>, a collection of indie developers writing about their development experiences.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;count=horizontal&amp;text=XS%20Force%20Art%20and%20Level%20Progress" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;count=horizontal&amp;text=XS%20Force%20Art%20and%20Level%20Progress" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rocket5studios.com%2Fdev-diary%2Fxs-force-art-and-level-progress%2F&amp;title=XS%20Force%20Art%20and%20Level%20Progress" id="wpa2a_10"><img src="http://www.rocket5studios.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.rocket5studios.com/dev-diary/xs-force-art-and-level-progress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Make A 2D Game With Unity3D Using Only Free Tools Part 4</title>
		<link>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-4/</link>
		<comments>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-4/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 20:26:14 +0000</pubDate>
		<dc:creator>Tim Miller</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.rocket5studios.com/?p=1102</guid>
		<description><![CDATA[This is part 4 of our tutorial series on making a 2D game in Unity3D with freely available tools and plugins. Part 1 introduced you to the tools we&#8217;re using, in Part 2 we built our first level and in Part 3 we hooked up the control scripts and setup the ladders and ropes so [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.rocket5studios.com/wp-content/uploads/2011/11/make_a_2d_game_part4_150.png" alt="Make A 2D Game In Unity3d Part 4" title="Make A 2D Game In Unity3d Part 4" width="150" height="150" class="alignleft size-full wp-image-1104" />This is part 4 of our tutorial series on making a 2D game in Unity3D with freely available tools and plugins.  <a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-in-unity3d-using-only-free-tools-part-1/" title="Make A 2D Game in Unity3D Using Only Free Tools Part 1">Part 1</a> introduced you to the tools we&#8217;re using, in <a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/" title="Make A 2D Game with Unity3D Using Only Free Tools Part 2">Part 2</a> we built our first level and in <a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-3/" title="Make A 2D Game With Unity3D Using Only Free Tools Part 3">Part 3</a> we hooked up the control scripts and setup the ladders and ropes so that the player can navigate levels.  In this article we&#8217;re going to create a pickup item, hook up the scoring system and add the interface text which reports score, lives and level.</p>
<p>Hopefully you already went through part 2 and part 3 of the series, if you haven&#8217;t already you might want to go back and do them now so everything in this part will make sense.  </p>
<p>If you’d rather skip ahead, you can <a href="http://www.rocket5studios.com/files/Rocket5_2DGame_blogPt3a.zip" title ="download the project up to this point">download the project up to this point</a>. You can also <a href="http://www.rocket5studios.com/2dgametutorial/Rocket52DGamePart4.html" title="Play the web version of part 4">click here to play the game</a> as it will be at the end of Part 4.</p>
<h3>Adding The Scoring and Pickup Scripts</h3>
<p>The game is working great so far &#8211; the player can move, climb ladders and shimmy across ropes. Now we&#8217;re going to add a &#8220;gold chest&#8221; pickup item and an interface to track scoring, player lives and the current level.</p>
<ul>
<li><a href="http://www.rocket5studios.com/files/Rocket5_2DGame_Scripts_pt4.zip" title="Download Rocket5_2DGame_Scripts_pt4.zip">Download scoring and pickup scripts</a> and unzip the file somewhere on your hard drive.</li>
<li>Copy <em>Scoring.cs</em> and <em>Pickup.cs</em> from the extracted .zip file and paste them into your project&#8217;s <em>Assets/Scripts</em> folder.</li>
</ul>
<h4>Modifications To Existing Scripts:</h4>
<p>You&#8217;re going to need to make a few changes to the scripts from part 3 so that these new scripts will work.</p>
<ul>
<li>Open <em>xa.cs</em> script and then uncomment the first line in the Class:</li>
</ul>
<pre class="brush:csharp">
public static Scoring sc;
</pre>
<ul>
<li>In the Start function, uncomment this line:</li>
</ul>
<pre class="brush:csharp">
sc = (Scoring)(this.gameObject.GetComponent("Scoring"));
</pre>
<ul>
<li>Open <em>Player.cs</em>, find the OnTriggerEnter function (line 256) and then uncomment the following code block:</li>
</ul>
<pre class="brush:csharp">
if (other.gameObject.CompareTag("Pickup"))
{
	if (other.GetComponent&lt;Pickup>())
	{
		other.GetComponent&lt;Pickup>().PickMeUp();
		xa.sc.Pickup();
	}
}
</pre>
<h3>Making The Pickup Sprite</h3>
<p>You might remember from part 2, that you already added the <em>pickup.png</em> to the <em>level</em> sprite atlas and then created a <em>level</em> container object that points to the sprite atlas so we don&#8217;t need to do any additional Container setup to create the pickup.</p>
<ul>
<li>Drag &#038; drop the Sprite object from <em>Orthello –> Objects –> Sprites</em> into the Hierarchy or Scene which will create a new object named something like “Sprite (id=-3700)“. Rename that object to “<em>pickup</em>“.</li>
<li>Drag the level object that we created in part 2 from <em>OT –> Containers</em> and drop it on to the <strong>Sprite Container</strong> slot in the Inspector.</li>
</ul>
<p>Your sprite will appear but it looks like the brick sprite that we made before, that’s because the brick is the first texture on the Sprite Atlases index. </p>
<ul>
<li>Click and hold your mouse over the word “<strong>Frame Index</strong>” in the inspector (with the pickup object selected) and then drag the mouse to the right to scroll through the textures on the sprite atlas. The pickup texture is at index <strong>16</strong> so set it to that. The sprite should now look like a a white rectangle with a red box in the center and a black background.</li>
</ul>
<h4>Adjusting The Collision:</h4>
<p>The sprite is a square, but we only want the object to be picked up only when the player touches the white part of the pickup.</p>
<ul>
<li>Check the <strong>Collidable</strong> checkbox to add collision to the object.</li>
<li>Open up the drop down list next to <strong>Physics</strong> and then select <strong>Custom</strong>.</li>
<li>Under <strong>Box Collider</strong>, set the <strong>Center Y</strong> to <em>-0.15</em>, <strong>Size X</strong> to <em>0.8</em> and <strong>Size Y</strong> to <em>0.5</em>.  Leave <strong>Size Z</strong> set to <em>0.4</em>.</li>
</ul>
<h4>Setting The Tag:</h4>
<p>We need to tag the pickup so that the player will trigger it when touched.</p>
<ul>
<li>Create a new tag by going to <em>Edit &#8211;> Project Settings &#8211;> Tags</em></li>
<li>Add a new <strong>Tag</strong> in the Tags list (probably in Element 3 if you&#8217;ve been following the series) named &#8220;<em>Pickup</em>&#8221; (without the quotes).  <em>It&#8217;s important that the name is correct since Player.cs looks for this exact name.</em></li>
<li>Select the pickup object in the Hierarchy, then click on the drop down list next to <strong>Tags</strong> at the top of the Inspector and then select <strong>Pickup</strong>.</li>
</ul>
<h4>Add The Script and Make It A Prefab</h4>
<p>Now we just need to add the <em>Pickup.cs</em> script to the sprite so that it will get &#8220;picked up&#8221; when the player touches it and we also need to turn it into a prefab so that it&#8217;s easy to place in all your levels.</p>
<ul>
<li>Drag the <em>Pickup.cs</em> script from the Project Scripts folder and drop it on to the <strong>pickup</strong> sprite in the Hierarchy.</li>
<li>Drag the <em>pickup</em> object from the Hierarchy into the <em>Prefabs</em> folder in the Project tab to create prefab from the object.</li>
</ul>
<p>The pickup is designed so that you can snap the bottom edge (the black part) of the sprite to the top edge of a brick sprite the white part of the powerup will be the correct height from the top of the brick. Duplicate your new pickup prefab a few times and place it around you level.</p>
<p>If you followed all of the steps so far, your pickup should look like this:<br />
<a href="http://www.rocket5studios.com/wp-content/uploads/2011/11/2dGamePt4-pickup.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/11/2dGamePt4-pickup.png" alt="2dGamePt4 pickup" title="2dGamePt4 pickup" width="536" height="536" class="alignnone size-full wp-image-1117" /></a></p>
<h3>Add The Interface Text</h3>
<p>At this point if you place the pickup in your level so that the player can pick it up, the sprite will disappear correctly as if he picked it up, but you&#8217;ll get some errors in the console because the Scoring script isn&#8217;t in the scene yet and we don&#8217;t have any UI to report the score.  So let&#8217;s fix that.</p>
<ul>
<li>First add the <em>Scoring.cs</em> script to the scene: Drag <em>Scoring.cs</em> from your Project&#8217;s Scripts folder and drop it on to the <strong>Scripts</strong> object in the Hierarchy.  If you select the <strong>Scripts</strong> object, you&#8217;ll see that the <strong>Scoring</strong> script has a bunch of slots for text objects that we need to add &#8211; but first we need to create the text objects.</li>
<li>Download the <a href="http://www.rocket5studios.com/files/G7_Silkworm.zip" title="Download G7_Silkworm.zip">G7 Silkworm font</a> and unzip the file somewhere on your computer.  This font isn&#8217;t exactly the same as the one used in the original Lode Runner game, but it&#8217;s pretty close.  If there&#8217;s another font you&#8217;d rather use, go for it.  And if you find a font that&#8217;s closer to the Lode Runner font, please let me know in the comments.</li>
<li>Create a new folder in your <em>Assets</em> folder named <em>Fonts</em>, locate the <em>silkworm.TTF</em> font on your hard drive and then copy it into the <em>Assets/Fonts</em> folder.</li>
<li>In Unity, select the <em>silkworm</em> font in your Project&#8217;s Fonts folder and then in the Inspector set the <strong>Font Size</strong> to <em>26</em>.</li>
</ul>
<h4>Adding The Score Text:</h4>
<ul>
<li>Drag the <em>silkworm</em> font from the <strong>Fonts</strong> folder in the Project panel and drop it into the Hierarchy.  This will automatically create a new <strong>GUI Text</strong> object in the Hierarchy using the <em>silkworm</em> font.</li>
<li>Rename the object to &#8220;<em>Score Label</em>&#8220;</li>
<li>In the <strong>Text</strong> field under GUIText in the Inspector, type &#8220;<em>SCORE</em>&#8221; in all caps without the quotes.  The Silkworm font only has uppercase letters so don&#8217;t try to use lowercase letters.</li>
<li>When you add a font to the scene, the X and Y position are automatically set to X 0.5 and Y 0.5, but we&#8217;re going to set the position of our fonts using the Pixel Offset so reset the <strong>X</strong> and <strong>Y Position</strong> to <em>0</em>.</li>
<li>Change <strong>Pixel Offset X</strong> to <em>16</em> and <strong>Pixel Offset Y</strong> to <em>592</em>.  This should position the <em>SCORE</em> text to the upper left hand corner of the Game view (note you won&#8217;t see the text in the Scene view so look at the Game view to help position the text).</li>
</ul>
<p>We also want to keep the scene nicely organized and make it a little easier to hook up the interface objects to the Scoring script later on.  You&#8217;re going to make the Score Label object a child of the Scripts object and then you&#8217;ll duplicate each of the other text objects from this one in order to save a few of the setup steps.</p>
<ul>
<li>Select the <em>Score Label</em> object in the Hierarchy and then drag and drop it onto the <em>Scripts</em> object in the Hierarchy so that it becomes a child of the Scripts object.</li>
<li>Expand the little arrow next to the <em>Scripts</em> object, select <em>Score Label</em> object and then duplicate it.</li>
<li>Rename the new text object to &#8220;<em>Score Value</em>&#8220;.</li>
<li>Change the <strong>Text</strong> to <em>0000000</em> (7 zeroes).</li>
<li>Change the <strong>Pixel Offset X</strong> to <em>150</em> and leave the <strong>Y</strong> set to <em>592</em>.</li>
</ul>
<h4>Adding The Lives Text:</h4>
<ul>
<li>Select either the Score Label or the Score Value text object and duplicate it.</li>
<li>Rename the new text object to &#8220;<em>Lives Label</em>&#8220;</li>
<li>Change the Text to <em>LIVES</em>.</li>
<li>Change the <strong>Pixel Offset X</strong> to <em>348</em> and leave <strong>Y</strong> set to <em>592</em>.</li>
<li>Duplicate <em>Lives Label</em> object and rename it to &#8220;<em>Lives Value</em>&#8220;.</li>
<li>Change the <strong>Text</strong> to <em>000</em> (3 zeroes).</li>
<li>Change the <strong>Pixel Offset X</strong> to <em>480</em> and leave <strong>Y</strong> set to <em>592</em>.</li>
</ul>
<h4>Adding The Level Text:</h4>
<ul>
<li>Select one of the other text objects you already created and duplicate it.</li>
<li>Rename the new text object to &#8220;<em>Level Label</em>&#8220;</li>
<li>Change the <strong>Text</strong> to <em>LEVEL</em>.</li>
<li>Change the <strong>Pixel Offset X</strong> to <em>576</em> and leave <strong>Y</strong> set to <em>592</em>.</li>
<li>Duplicate <em>Level Label</em> and rename the new object to &#8220;<em>Level Value</em>&#8220;</li>
<li>Change the <strong>Text</strong> to <em>000</em> (3 zeroes).</li>
<li>Change the <strong>Pixel Offset X</strong> to <em>710</em> and leave <strong>Y</strong> set to <em>592</em>.</li>
</ul>
<h4>Hooking Up The Scripts:</h4>
<p>Now we need to connect the interface text objects to the Scoring script.</p>
<ul>
<li>Select the <em>Scripts</em> object in the Hierarchy.  Under the Scoring script in the Inspector, you&#8217;ll see slots for each of the GUIText objects we just created.</li>
<li>Select each of the text objects from the Hierarchy and drag and drop them into the corresponding slot on the Scoring script.  For example, drag <em>Level Label</em> and drop it on to the <em>Level Label Text</em> field.</li>
</ul>
<p>Once all of the text objects are connected to the <em>Scoring</em> script, press <strong>Play</strong> in Unity.  You should see the SCORE, LIVES and LEVEL text turn to a red color that matches the border color and the number of lives should change to 005 and the level number should change to 001.  </p>
<p>Now if you run the character over a pickup object in the game, the Score should increase by 250.</p>
<h3>Make The Top Border</h3>
<p>To help keep the interface text separate from the gameplay area, we&#8217;re going to add a thin border just under the interface text.</p>
<ul>
<li>Create a new cube by going to <em>Game Object &#8211;> Create Other &#8211;> Cube</em></li>
<li>Rename the object to &#8220;<em>border top</em>&#8220;.</li>
<li>Set the <strong>Transform Position X</strong> to <em>0</em>, <strong>Y </strong>to <em>8.7</em> and <strong>Z</strong> to <em>1</em>.</li>
<li>Set the <strong>Scale X</strong> to <em>26</em>, <strong>Y</strong> to <em>0.2</em> and <strong>Z</strong> to <em>1</em>.</li>
<li>Find the <em>border</em> material in the Materials folder and then drag and drop it on to the <em>border top</em> object.  We created the border material in a previous article.</li>
</ul>
<p>If you followed all of the steps above, then your Hierarchy and Inspector (with the Scripts object selected) should look the following:</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/11/2dGamePt4-scoringtext1.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/11/2dGamePt4-scoringtext1.png" alt="2dGamePt4 Scoring Text" title="2dGamePt4 Scoring Text" width="502" height="362" class="alignnone size-full wp-image-1125" /></a></p>
<h3>Creating The GLOBAL Prefab</h3>
<p>Next we want to do some things to keep the scene nicely organized and also to make it easy to add the key components to any new levels that you create.  We&#8217;re going to create a GLOBAL prefab that contains the Main Camera, the Scripts (which includes the interface text objects) and the top and bottom borders.</p>
<ul>
<li>Create an empty game object by boing to <em>Object &#8211;> Create Empty</em>, zero out the transforms so that it&#8217;s at 0,0,0 on the X,Y,Z and then rename the object to &#8220;<em>GLOBAL</em>&#8220;.</li>
<li>Select the <em>Main Camera</em> in the Hierarchy and then drag and drop it onto the <em>GLOBAL</em> object so that the Main Camera becomes a child of GLOBAL.</li>
<li>Select the <em>Scripts</em> object in the Hierarchy and drag and drop it onto the <em>GLOBAL</em> object.</li>
<li>Select the <em>border bottom</em> and <em>border top</em> objects (make sure they&#8217;re not already a child of some other game object first) and drag and drop them onto the <em>GLOBAL</em> object.</li>
</ul>
<p>That&#8217;s everything we need for the GLOBAL object, so now let&#8217;s turn it into a prefab that can be easily added to other levels and updated later if we need to make changes.</p>
<ul>
</li>
<p>Select the <em>GLOBAL</em> object in the Hierarchy and then drag and drop it onto the <strong>Prefabs</strong> folder in the Project panel.</li>
<h3>Creating The Player Prefab</h3>
<p>In Part 3 of the series, I forgot to create a prefab from our player character, so let&#8217;s do that now if you haven&#8217;t already.</p>
<ul>
<li>Select the <em>player</em> object in the Hierarchy and zero his Transform position X to 0, Y to 0 and leave the Z position set to -1.  This step is optional, I just like to have my game objects centered when I initially create a prefab.</li>
</ul>
<p>If you&#8217;ve followed all of the steps so far, then your Project and scene Hierarchy should look like the following image:<br />
<a href="http://www.rocket5studios.com/wp-content/uploads/2011/11/2dGamePt4-globalprefab.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/11/2dGamePt4-globalprefab.png" alt="2dGamePt4 Global Prefab" title="2dGamePt4 Global Prefab" width="412" height="320" class="alignnone size-full wp-image-1126" /></a></p>
<h3>Conclusion</h3>
<p>We&#8217;re getting a lot closer to having a complete game.  Over the course of the next few tutorials I hope to add enemy AI (still working on a good solution for them), breakable bricks, a front end interface, an exit ladder (for exiting levels), some kind of manager for keeping track of your current level and a few other things like a game over screen.  Let me know in the comments if there are other things you&#8217;d like to see covered.</p>
<p>If you followed all of the steps so far, then your game should look something like this image (click to see a larger version):</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/11/2dGamePt4-gameview.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/11/2dGamePt4-gameview-sm.png" alt="2dGamePt4 Game Shot" title="2dGamePt4 Game Shot" width="536" height="433" class="alignnone size-full wp-image-1129" /></a></p>
<p>You can <a href="http://www.rocket5studios.com/files/Rocket5_2DGame_blogPt4.zip" title="Download Rocket5_2DGame_blogPt4.zip">download the project up to this point</a> and you can <a href="http://www.rocket5studios.com/2dgametutorial/Rocket52DGamePart4.html" title="Play the web version">play the web version of the project here</a>.</p>
<p>If you like this post, please be sure to say hi in the comments and follow me on <a href="http://www.twitter.com/rocket5studios" title="Rocket 5 on Twitter">Twitter</a> and <a href="http://www.facebook.com/rocket5studios" title="Rocket 5 on Facebook">Facebook</a>. Your support helps to keep these tutorial coming. This blog post is part of <a href="http://idevblogaday.com/" title="iDevBlogADay">iDevBlogADay</a>, a collection of indie developers writing about their development experiences.</p>
<h3>More Tutorials In This Series</h3>
<p><a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-in-unity3d-using-only-free-tools-part-1/" title="Make A 2D Game in Unity3D Using Only Free Tools Part 1">Make A 2D Game in Unity3D Using Only Free Tools Part 1</a><br />
<a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/" title="Make A 2D Game with Unity3D Using Only Free Tools Part 2">Make A 2D Game with Unity3D Using Only Free Tools Part 2</a><br />
<a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-3/" title="Make A 2D Game With Unity3D Using Only Free Tools Part 3">Make A 2D Game With Unity3D Using Only Free Tools Part 3</a></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;count=horizontal&amp;text=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%20Part%204" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;count=horizontal&amp;text=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%20Part%204" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-4%2F&amp;title=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%20Part%204" id="wpa2a_12"><img src="http://www.rocket5studios.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-4/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Make A 2D Game With Unity3D Using Only Free Tools Part 3</title>
		<link>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-3/</link>
		<comments>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-3/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 17:03:42 +0000</pubDate>
		<dc:creator>Tim Miller</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.rocket5studios.com/?p=1019</guid>
		<description><![CDATA[Welcome to Part 3 in this series on making a 2D sprite-based game with Unity 3D. In Part 1 I introduced you to the tools we&#8217;ll be using to make a Lode Runner style action game and in Part 2 we created the level sprites and built our first level. In this tutorial we&#8217;re going [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/make_a_2d_game_part3_150.png" alt="" title="Make A 2D Game With Unity3D Part 3" width="150" height="150" class="alignleft size-full wp-image-1020" />Welcome to Part 3 in this series on making a 2D sprite-based game with Unity 3D.  In <a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-in-unity3d-using-only-free-tools-part-1/" title="Make A 2D Game in Unity3D Using Only Free Tools Part 1">Part 1</a> I introduced you to the tools we&#8217;ll be using to make a Lode Runner style action game and in <a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/" title="Make A 2D Game with Unity3D Using Only Free Tools Part 2">Part 2</a> we created the level sprites and built our first level.  In this tutorial we&#8217;re going to be adding in the player, hooking up the scripts and adding collision to the ladders and ropes so that you&#8217;ll finally be able to run the character around in your levels.</p>
<p>This tutorial assumes that you have already followed along with Part 2 of this series so your project should be ready to continue on with the steps below.  If you haven&#8217;t already done Part 2, <a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/" title="Make A 2D Game with Unity3D Using Only Free Tools Part 2">you should go back and do that first</a> so you can get a full understanding of how everything fits together.  If you&#8217;d rather skip ahead, you can <a href="http://www.rocket5studios.com/files/Rocket5_2DGame_blogPt2b.zip" title="Download Rocket5_2DGame_blogPt2b.zip">download the project up to this point</a>.   You can also <a href="http://www.rocket5studios.com/2dgametutorial/Rocket52DGamePart3.html" title="Play Rocket 5 2D Game Part3" target="_blank">click here to see how the game will look at the end of Part 3</a>.</p>
<h3>Making the Player Sprite Atlas</h3>
<p>If you&#8217;ve been following the series, I know you&#8217;re excited to get the player character running around in the game, so the first thing we need to do is create a sprite atlas in <a href="http://www.texturepacker.com/" title="Sprite sheet maker, image packer and optimizer" target="_blank">TexturePacker</a>.</p>
<ul>
<li><a href="http://www.rocket5studios.com/files/Rocket5_2DGame_LevelSprites.zip" title="Rocket5_2DGame_LevelSprites.zip">Download the source sprite .png’s</a> and unzip the file somewhere on your hard drive.  If you already downloaded the sprites and added them to your project in Part 2, then you can skip this step. </li>
<li>Launch TexturePacker and then drag &#038; drop all of the <em>.png</em> files from the <em>sprites/player</em> folder into the <strong>Sprites</strong> panel.</li>
</ul>
<h4>Texture Settings / Layout:</h4>
<ul>
<li>Set <strong>Algorithm</strong> to <strong>Basic</strong></li>
<li>Set <strong>Border Padding</strong> to <em>1</em></li>
<li>Set <strong>Shape Padding</strong> to <em>1</em></li>
<li>Uncheck <strong>Trim</strong></li>
</ul>
<h4>Texture Settings / Output:</h4>
<ul>
<li>Leave the <strong>Data format</strong> set to <em>cocos2d</em>.</li>
<li>Under <strong>Data File</strong>, click the little “…” button and browse to the location in your project’s Asset folder where you want to store your sprites (I put mine in <em>Assets/SpriteAtlases</em>), name the file “<em>player</em>” and then click <strong>Save</strong>.</li>
<li>TexturePacker automatically adds the <em>.plist</em> extension to the <strong>Data File</strong>, but Unity wants the file to be <em>.xml</em>. So in the text field, replace <em>.plist</em> with <em>.xml</em>.</li>
<li>The <strong>Texture File</strong> path should already be set to the same location as the <em>.xml</em> file except that it will have a <em>.png</em> extension so there’s nothing to do there.</li>
</ul>
<p>If you followed the steps above, then your settings in TexturePacker should look like this (click the image to see a larger version):</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-texturepacker-player-lg.png" target="_blank"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-texturepacker-player-sm.png" alt="" title="2dGamePt3 TexturePacker Player Sprite Atlas" width="536" height="615" class="alignnone size-full wp-image-1036" /></a></p>
<p>Now if you click the <strong>Publish</strong> icon in <strong>TexturePacker</strong> and then switch back to Unity, you should see a <em>player.png</em> file and a <em>player.xml</em> file in the <strong>SpriteAtlases</strong> folder in the Project view.</p>
<p>If you don&#8217;t already have the project open in Unity, open it now and then load the scene that you created in Part 2 (eg. <em>level1.scene</em>).</p>
<p>We need to make a couple of changes to the sprite atlas in Unity so that it looks correct.</p>
<ul>
<li>Select the <em>player.png</em> file in the Project tab. In the Inspector change the <strong>Filter Mode</strong> to <strong>Point</strong>.</li>
<li>Click the <strong>Override for Web</strong> box, set the <strong>Format</strong> to <strong>Truecolor</strong> and then click <strong>Apply</strong>.</li>
</ul>
<h3>Making the Player Sprite</h3>
<p>Now we&#8217;re ready to turn the player&#8217;s sprite atlas into animated sprites using the <a href="http://www.wyrmtale.com/products/unity3d-components/orthello" title="Orthello 2D Framework" target="_blank">Orthello 2D</a> plugin.</p>
<h4>The Sprite Container:</h4>
<ul>
<li>In the Unity Project tab, expand the Orthello folders: <em>Orthello –> Objects –> Sprites –> SpriteAtlas</em> and then drag the <strong>SpriteAtlas-Cocos2D</strong> object into the Hierarchy.</li>
<li>In the Hierarchy tab, expand the <strong>OT</strong> object and then the Containers object and you will see your new container with a name something like “Container (id=-6840)“. This is the Container that will hold all of our <em>player</em> sprites from the atlas we made so you can rename the Container to something obvious like “player“.</li>
<li>Drag the <em>player.png</em> from the <strong>SpriteAtlases</strong> folder and drop it on the “<strong>OTSprite Atlas Cocos 2D</strong>” script&#8217;s <strong>Texture</strong> slot.</li>
<li>Drag the <em>player.xml</em> from the Project, <strong>SpriteAtlases</strong> folder and drop it on to the <strong>Atlas Data File</strong> slot. Now if you drop down the little Atlas Data arrow, you should see that it’s populated with all the sprite atlas data that TexturePacker generated for us.</li>
</ul>
<h4>Setting Up The Player Animations:</h4>
<p>Now we need to assign all of the frames from the sprite atlas to individual animations.</p>
<ul>
<li>Drag an <strong>Animation</strong> object from <em>Orthello –> Objects –> Sprites</em> into the Hierarchy. This will add a new object under <em>OT –> Animations</em> named something like “Animation (id=-4320)“. Rename this object to “<em>player anims</em>“.</li>
<li>With the new &#8220;<em>player anims</em>&#8221; OTAnimation still selected, adjust the settings to match those in the following image. To populate the <strong>Container</strong> field, drag &#038; drop the “<em>player</em>” object from <em>OT –> Containers</em> on to the <strong>Container</strong> field.</li>
</ul>
<p>Click the image to see all of the animation settings:<br />
<a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-PlayerAnims-lg.png" target="_blank"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-PlayerAnims-sm.png" alt="" title="2dGamePt3 Player Animations" width="386" height="411" class="alignnone size-full wp-image-1045" /></a></p>
<h4>Making The Player Sprite</h4>
<ul>
<li>Next find the <strong>AnimatingSprite</strong> object in <em>Orthello –> Objects –> Sprites</em> object in the Project tab and drag it into the Hierarchy, this will make a new object in the scene with a name like “Animating Sprite (id=-23050)“. Rename this object “<em>player</em>“.</li>
<li>With the new <em>player</em> object still selected in the Hierarchy, drag the “<strong>player anims</strong>” object on to the <strong>Animation</strong> slot. The <strong>Sprite Container</strong> slot should automatically fill with a reference to the “<em>player</em>” container object, if it doesn’t you can drag &#038; drop that onto the slot.</li>
<li>Now you should see the player sprite in your scene and if you press <strong>Play</strong> in Unity, the sprite will animate through all of the frames in all of the animations. We don’t want the animation to play on start so uncheck the <strong>Play On Start</strong> checkbox.</li>
</ul>
<h3>Adding Collision To The Player</h3>
<p>In order for the player to collide correctly with the ladder and rope colliders we&#8217;ll be creating later, we need to set the following.</p>
<ul>
<li>With the the <em>player</em> &#8220;OTAnimating Sprite&#8221; still selected in the Hierarchy, check the check box next to <strong>Collidable</strong>.   This will automatically add a Rigidbody component to the object.</li>
<li>Click the dropdown list next to <strong>Physics</strong> and  select <strong>Custom</strong> from the list.</li>
<li>Under <strong>Transform</strong>, set the <strong>Scale Z</strong> to <em>1</em>.</li>
<li>Change the <strong>Depth</strong> to <em>-1</em>.</li>
<li>Under <strong>Box Collider</strong>, set <strong>Center Y</strong> to <em>-0.1</em> and <strong>Z</strong> to <em>1</em>.  Change<strong> Size X</strong> to <em>0.45</em>, <strong>Y</strong> to <em>0.6</em> and <strong>Z</strong> to <em>0.4</em>.</li>
</ul>
<p>If you followed the steps above, the settings on the player sprite should look like the following image.</p>
<p>Click on the image to see all of the settings:<br />
<a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-playerSpriteSettings-lg.png" target="_blank"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-playerSpriteSettings-sm.png" alt="" title="2dGamePt3 Player Sprite Settings" width="386" height="411" class="alignnone size-full wp-image-1050" /></a></p>
<p>Changing the Depth to -1 and the Center Z to 1 on the Box Collider will position the Collision at 0 on the Z axis while moving the player sprite 1 unit towards the camera.  This has 2 effects: it makes sure that the player will always be visible in front of the level sprites while keeping the collision at 0 on the Z so that it will collide with the ladder and rope triggers.  It sounds kinda strange, but you can see how it should look in this screen shot:</p>
<p><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-playerCollision.png" alt="2dGamePt3 Player Collision" title="2dGamePt3 Player Collision" width="367" height="371" class="alignnone size-full wp-image-1052" /></p>
<h3>Setting Up The Shooting Animation</h3>
<p>We need to add another animating sprite so that when you press the fire button, you&#8217;ll see a bullet blob animate from the player and hit the ground.</p>
<h4>The Shoot Animation:</h4>
<ul>
<li>Drag an <strong>Animation</strong> object from <em>Orthello –> Objects –> Sprites</em> into the Hierarchy. This will add a new object under <em>OT –> Animations</em> named something like “Animation (id=-4320)“. Rename this object to “<em>shoot anim</em>“.</li>
<li>With the new &#8220;<em>shoot anim</em>&#8221; OTAnimation still selected, adjust the settings to match those in the following image. To populate the Container field, drag &#038; drop the “level” object from <em>OT –> Containers</em> on to the <strong>Container</strong> field.  Remember that we already added the shoot sprite animation to the level sprite atlas in Part 2 of the series.</li>
</ul>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-shootSpriteAnims-lg.png" target="_blank"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-shootSpriteAnims-lg.png" alt="2dGamePt3 Shoot Sprite Animations" title="2dGamePt3 Shoot Sprite Animations" width="386" height="265" class="alignnone size-full wp-image-1055" /></a></p>
<h4>The Shoot Sprite</h4>
<ul>
<li>Next find the <strong>AnimatingSprite</strong> object in <em>Orthello –> Objects –> Sprites</em> in the Project tab and drag it into the Hierarchy, this will make a new object in the scene with a name like “Animating Sprite (id=-23050)“. Rename this object “<em>shoot</em>“.</li>
<li>With the new <em>shoot</em> object still selected in the Hierarchy, drag the “<em>shoot anim</em>” object on to the <strong>Animation</strong> slot. The <strong>Sprite Container</strong> slot should automatically fill with a reference to the “<em>level</em>” container object, if it doesn’t you can drag &#038; drop that onto the slot.</li>
<li>Set the <strong>Transform Position X</strong> to <em>-1</em> so that the sprite is position to the left of the player&#8217;s sprite.</li>
<li>Set the <strong>Depth</strong> to <em>-1</em> so that the sprites will appear in front of the level sprites.</li>
<li>Set the <strong>Frame Index</strong> to <em>18</em>.</li>
</ul>
<p>Now you should see the shoot sprite in your scene and if you press <strong>Play</strong> in Unity, the sprite will animate through all of the frames in all of the animations. We don’t want the animation to play on start so uncheck the <strong>Play On Start</strong> checkbox.</p>
<p>We only want to see the shoot sprite when the player is actually shooting so uncheck the checkbox next to <strong>Mesh Render</strong> on the <em>shoot</em> sprite.  This will hide the sprite in the scene until we show it again later with a script.</p>
<h4>Parenting The Shoot Sprite</h4>
<p>We want the sprite to move with the player and we also need to flip the sprite so that it&#8217;s either on the player&#8217;s left or right side depending on which way the character is facing.</p>
<ul>
<li>Go to Game Object &#8211;> Create Empty</li>
<li>Rename this object to &#8220;<em>shoot parent</em>&#8221; and make sure the <strong>X, Y, Z Position</strong> on the object is set to <em>zero</em>.</li>
<li>In the Hierarchy, drag and top the <em>shoot</em> sprite on to the <em>shoot parent</em> so that the <em>shoot</em> sprite becomes a child of the <em>shoot parent</em> object.</li>
<li>Drag and drop the <em>shoot parent</em> object on to the <em>player</em> sprite so that it&#8217;s a child of the <em>player</em>.</li>
</ul>
<p>If you followed all the steps so far, your Hierarchy should look something like the following image.  Note that I put all of my level tiles under an empty game object named <em>LEVEL</em> to keep things organized.</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-PlayerParenting-lg.png" target="_blank"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-PlayerParenting-lg.png" alt="2dGamePt3 Player Parenting" title="2dGamePt3 Player Parenting" width="221" height="285" class="alignnone size-full wp-image-1058" /></a></p>
<p><em>Note that in order for the scripts to work, the child objects under the player must be named exactly as shown in the above image.</em></p>
<h3>Hooking Up The Scripts</h3>
<p>We&#8217;re finally ready to add the scripts so that the player can move!</p>
<ul>
<li><a href="http://www.rocket5studios.com/files/Rocket5_2DGame_Scripts_Pt3.zip" title="Download Rocket5_2DGame_Scripts_Pt3.zip">Download the player scripts</a> and unzip the file somewhere on your hard drive.</li>
<li>Drag the <strong>Scripts</strong> folder from the <em>.zip</em> into your project&#8217;s <strong>Asset</strong> folder.</li>
<li>Create an empty game object by going to <em>Game Object &#8211;> Create Empty</em></li>
<li>Rename the new object to something like &#8220;<em>Scripts</em>&#8220;.</li>
<li>Drag and drop the <em>xa.cs</em> file from the Project tab onto the <em>Scripts</em> object in the Hierarchy.</li>
<li>Drag and drop the <em>player.cs</em> and the <em>playerAnims.cs</em> files from the Project tab on to the <em>player</em> object in the Hierarchy.</li>
<li>Make sure that the player is positioned above a brick tile so that she has something to stand on.  Remember that it&#8217;s the player&#8217;s Box Collider that actually collides with objects in the world and not the visible sprite object, so the box will be positioned at something like 0,0,-1 (X and Y can be anywhere in the level but Z should always be -1).</li>
</ul>
<p>Now if everything is setup correctly, when you press Play in Unity the player should stand on a brick tile without falling through it.  And if you press left and right on the keyboard the player should move and the run animations should play.</p>
<p>Describing how the scripts work is beyond the scope of this tutorial, but I did add comments to the scripts that should hopefully help you understand how everything is working.  If you have questions about anything in the scripts, please feel free to ask in the comments below or email me directly.</p>
<h3>Adding The Ladder Colliders</h3>
<p>In order for the ladders to work, we need to add colliders to them.</p>
<h4>Creating A Ladder:</h4>
<ul>
<li>Go to <em>GameObject &#8211;> Create Other &#8211;> Cube</em></li>
<li>Rename the Cube to something like &#8220;<em>Ladder</em>&#8220;.</li>
<li>Open the <strong>Tag Manager</strong> by going to to <em>Edit &#8211;> Project Settings &#8211;> Tags</em></li>
<li>Under <strong>Tags</strong> in the next available slot (probably Element 1) type &#8220;<em>Ladder</em>&#8221; and then in the next slot after that, type in &#8220;<em>Rope</em>&#8221; (without the quotes).</li>
<li>While we&#8217;re here, we need to add another layer.  Under the next empty <strong>User Layer</strong> (probably User Layer 9), type &#8220;<em>NoDraw</em>&#8221; (without the quotes).</li>
<li>Now click on the Ladder cube you created before and change the Tag to &#8220;<em>Ladder</em>&#8221; and then change the Layer to &#8220;<em>NoDraw</em>&#8220;.</li>
</ul>
<h4>Hiding Objects In The Game View:</h4>
<p>You&#8217;ve probably noticed that the Ladder collider is visible in the Game view but we don&#8217;t want to see these in the actual game.  To hide them, we need to make a change to the camera.</p>
<ul>
<li>Click on the <strong>Main Camera</strong> object in the Hierarchy.</li>
<li>Under <strong>Camera</strong>, drop down the list next to <strong>Culling Mask</strong> and click on &#8220;<em>NoDraw</em>&#8221; to deselect it. Now any object that is in the &#8220;NoDraw&#8221; layer will be hidden in the Game view.</li>
</ul>
<h4>Sizing And Positioning The Ladder:</h4>
<p>Every ladder in the scene needs to have one of these Ladder colliders and we need to adjust the size of the Ladder colliders to match the height of each of the ladders in the level.  The ladder collider needs to be 1 unit taller than the visible ladder &#8211; so if your ladder is 4 tiles (sprites) tall, then the collider needs to be 5 units tall.</p>
<ul>
<li>Assuming your ladder is 4 sprites high: Select the <strong>Ladder</strong> collider and change the<strong> Scale Y</strong> to <em>5</em> (1 unit taller than the visible ladder).</li>
<li>Snap the Ladder collider to one of the lower corners of the bottom sprite using the <a href="http://unity3d.com/support/documentation/Manual/Positioning%20GameObjects.html" title="vertex snap how to" target="_blank">Vertex Snap</a> feature in Unity.</li>
<li>You can duplicate this object, resize the Y and snap it to all the other ladder sprites in your level.</li>
</ul>
<p>Your ladder should look like this (click to see a larger version):<br />
<a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-LadderTrigger-lg.png" target="_blank"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-LadderTrigger-sm.png" alt="2dGamePt3 Ladder Trigger" title="2dGamePt3 Ladder Trigger" width="200" height="313" class="alignnone size-full wp-image-1062" /></a></p>
<p>Now if you press <strong>Play</strong> in Unity and then walk the player over to the ladder, she should be able to climb up and down the ladder, the player&#8217;s sprite should be playing the climb animation and you should be able to exit the ladder at the top and bottom levels and also fall off the ladder if you exit somewhere in the middle.</p>
<h3>Adding the Rope Colliders</h3>
<p>The rope colliders follow pretty much the same setup as the ladders.</p>
<h4>Creating A Rope:</h4>
<ul>
<li>Go to <em>GameObject &#8211;> Create Other &#8211;> Cube</em></li>
<li>Rename the Cube to something like &#8220;<em>Rope</em>&#8220;.</li>
<li>Change the <strong>Tag</strong> to &#8220;<em>Rope</em>&#8221; and then change the Layer to &#8220;<em>NoDraw</em>&#8220;.</li>
</ul>
<h4>Sizing And Positioning The Rope:</h4>
<p>Like the Ladders, every rope in the scene needs to have one of these Rope colliders.  But unlike the Ladders, the Rope colliders must be the same width as your rope sprites.</p>
<ul>
<li>Assuming your rope is 4 sprites wide: Select the Rope collider and change the <strong>Scale X</strong> to <em>4</em> (Y and Z scale should be 1).</li>
<li>Snap the Rope collider to one of the lower corners of the bottom sprite using the Vertex Snap feature.</li>
<li>You can duplicate this object, resize the X and snap it to all the other rope sprites in your level.</li>
</ul>
<p>Your rope should look like this (click to see a larger version):<br />
<a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-RopeTrigger-lg.png" target="_blank"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt3-RopeTrigger-sm.png" alt="2dGamePt3 Rope Trigger" title="2dGamePt3 Rope Trigger" width="536" height="329" class="alignnone size-full wp-image-1065" /></a></p>
<p>Now if you press Play in Unity and then walk the player over to the rope, she should be able to climb left and right along the rope, you should see the rope hang animation playing and if you press the down arrow while hanging from the rope, she should let go of the rope and fall.</p>
<h3>Conclusion</h3>
<p>Now you have everything you need to make levels that support the player&#8217;s full suite of movements: running, ladder climbing and rope shimmy.  In the next tutorial, we&#8217;re going to be adding the scoring system, breaking out brick tiles and picking up objects.</p>
<p>You can <a href="http://www.rocket5studios.com/files/Rocket5_2DGame_blogPt3a.zip" title="Download Rocket5_2DGame_blogPt3a.zip">download the project up to this point</a> and you can <a href="http://www.rocket5studios.com/2dgametutorial/Rocket52DGamePart3.html" title="Play Rocket 5 2D Game Part3" target="_blank">play the web version of the project here</a>.</p>
<p>If you like this post, please be sure to say hi in the comments and follow me on <a href="http://www.twitter.com/rocket5studios" title="Rocket 5 on Twitter">Twitter</a> and <a href="http://www.facebook.com/rocket5studios" title="Rocket 5 on Facebook">Facebook</a>. Your support helps to keep these tutorial coming. This blog post is part of <a href="http://idevblogaday.com/" title="iDevBlogADay" target="_blank">iDevBlogADay</a>, a collection of indie developers writing about their development experiences.</p>
<h4>Regarding The AI:</h4>
<p>When I began this series, It was my intention to include enemies that could follow the player around the level using behaviors similar to the original Lode Runner game.  However my time has become increasingly limited and my programming skills aren&#8217;t fully up to the task of recreating their AI so I might not be able to get AI into this the series.  </p>
<p>If you are a programmer who would like to contribute an AI behavior solution to this tutorial series, please contact me.</p>
<h3>More Tutorials In This Series</h3>
<p><a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-in-unity3d-using-only-free-tools-part-1/" title="Make A 2D Game in Unity3D Using Only Free Tools Part 1">Make A 2D Game in Unity3D Using Only Free Tools Part 1</a><br />
<a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/" title="Make A 2D Game with Unity3D Using Only Free Tools Part 2">Make A 2D Game with Unity3D Using Only Free Tools Part 2</a></p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;count=horizontal&amp;text=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%20Part%203" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;count=horizontal&amp;text=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%20Part%203" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-3%2F&amp;title=Make%20A%202D%20Game%20With%20Unity3D%20Using%20Only%20Free%20Tools%20Part%203" id="wpa2a_14"><img src="http://www.rocket5studios.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-3/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Make A 2D Game with Unity3D Using Only Free Tools Part 2</title>
		<link>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/</link>
		<comments>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 04:20:21 +0000</pubDate>
		<dc:creator>Tim Miller</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unity3D]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.rocket5studios.com/?p=947</guid>
		<description><![CDATA[Welcome to part 2 of this tutorial series on making a Lode Runner-style 2D game with Unity 3D. In part 1, I introduced you to a bunch of free tools and scripts that we&#8217;ll be using and showed you how to setup your project. In this post, I go over how to create the level [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/make_a_2dgame_part2_150.png" alt="" title="Make a 2d game in unity3d part 2" width="150" height="150" class="alignleft size-full wp-image-956" />Welcome to part 2 of this tutorial series on making a Lode Runner-style 2D game with Unity 3D.  In <a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-in-unity3d-using-only-free-tools-part-1/" title="Make A 2D Game with Unity3D Using Only Free Tools Part 2">part 1</a>, I introduced you to a bunch of free tools and scripts that we&#8217;ll be using and showed you how to setup your project.  In this post, I go over how to create the level sprites and build your first level.</p>
<p>Of all the Unity plugins we covered in part 1, the main plugin we&#8217;ll be focusing on in this installment of the series is <a href="http://www.wyrmtale.com/products/unity3d-components/orthello" title="Orthello 2D Framework">Orthello 2D</a>. Orthello was recently updated with a lot of cool new features (as I write this, 1.6a is the latest version) so make sure you&#8217;re using version 1.6a or newer.</p>
<h3>Initial Project Setup</h3>
<p>We need to make a few changes to the project settings before we start making the sprites.</p>
<h4>Build Settings:</h4>
<ul>
<li><em>File &#8211;> Build Settings&#8230;</em></li>
<li>Click on <strong>Web Player</strong> and then click <strong>Switch Platform</strong>. (You could leave this set to PC and Mac Standalone if you prefer.)</li>
<li>Close the Build Settings window.</li>
</ul>
<h4>Player Settings:</h4>
<ul>
<li><em>Edit &#8211;> Project Settings &#8211;> Player</em></li>
<li>Under <strong>Per-Platform Settings</strong> click on the little world icon (assuming you set your platform to Web Player in the previous step).</li>
<li>Click on <strong>Resolution and Presentation</strong> and change the <strong>Screen Width</strong> to <em>800</em> and the <strong>Screen Height</strong> to <em>600</em>.</li>
</ul>
<h4>Render Settings:</h4>
<p>Since you&#8217;re typically not going to use Unity&#8217;s lighting system in a 2D sprite-based game, we want to brighten things up in here by adjusting Unity&#8217;s default ambient light.  This step is optional.</p>
<ul>
<li><em>Edit &#8211;> Render Settings&#8230;</em></li>
<li>Click on <strong>Ambient Light</strong> and change the color to white (<em>255, 255, 255, 255</em>).</li>
</ul>
<h3>Initial Orthello 2D Setup</h3>
<ul>
<li>In the Unity Project tab, go to <em>Orthello &#8211;> Objects</em> and then drag the <strong>OT</strong> object into either the Scene or the Hierrachy tab.</li>
<li>In the Hierarchy tab, drop down the little arrow next to the <strong>OT</strong> object and then click on <strong>View</strong>.</li>
<li>Change the <strong>Pixel Perfect Resolution</strong> to <em>800</em> x <em>600</em> (same as we set for the Player Settings)</li>
<li>Change the <strong>Custom Size</strong> to <em>10</em></li>
</ul>
<p>Now if you select the <strong>Main Camera</strong> in the Hierarchy, you&#8217;ll see that Projection is set to Orthographic and Size is set to 10.  Orthello automatically changed the Projection from Perspective (Unity&#8217;s default setting) to Orthographic when you added the OT object into the scene.  And When we changed the Custom Size on the Orthello View object to 10, it set the Main Camera&#8217;s Size to 10. </p>
<p>With a bit of experimenting, I found that with a screen resolution of 800&#215;600 and an Orthographic Size of 10, a Cube at scale 1x1x1 will be exactly 30 pixels on screen which happens to be the exact size of the sprites we&#8217;re going to use to build the levels which should make it easy for us to stick to a grid when building levels.</p>
<p>At this point, your project should look something like the following image (click to see a larger image).  Note that I also added a Cube to the scene for scale comparison.</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-initialSceneSetup.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-initialSceneSetup-sm.png" alt="" title="2dGamePt2 - Initial Scene Setup" width="536" height="378" class="alignnone size-full wp-image-960" /></a></p>
<p><a href="http://www.rocket5studios.com/files/Rocket5_2DGame_blogPt2a.zip">Download the project up to this point</a>.</p>
<h3>Making The Level Sprite Atlas</h3>
<p>Ok now that all that initial setup stuff is out of the way, it&#8217;s time to dig in and have some fun.  The levels in Lode Runner were built using just a few simple tiles: Brick (digable), Concrete (un-digable), Ladder and Rope.</p>
<ul>
<li><a href="http://www.rocket5studios.com/files/Rocket5_2DGame_LevelSprites.zip" title="Rocket5_2DGame_LevelSprites.zip">Download the source sprite .png&#8217;s</a> and unzip the file somewhere on your hard drive.</li>
<li>Launch <a href="http://www.texturepacker.com/" title="TexturePacker Sprite sheet maker, image packer and optimizer">TexturePacker</a> and then drag &#038; drop all of the .png files from the <em>sprites/level</em> folder into the Sprites panel.</li>
<li>Then select all of the .png files in the <em>sprites/shoot</em> folder and drag those into the Sprites panel too.</li>
</ul>
<h4>Texture Settings / Layout:</h4>
<ul>
<li>Set <strong>Algorithm</strong> to <strong>Basic</strong></li>
<li>Uncheck <strong>Trim</strong></li>
<li>Uncheck <strong>Enable Auto Alias</strong>.</li>
</ul>
<h4>Texture Settings / Output:</h4>
<ul>
<li>Leave the <strong>Data</strong> format set to <strong>cocos2d</strong>.</li>
<li>Under <strong>Data File</strong>, click the little &#8220;&#8230;&#8221; button and browse the location in your project&#8217;s Asset folder where you want to store your sprites (I put mine in <em>Assets/SpriteAtlases</em>), name the file &#8220;<em>level</em>&#8221; and then click <strong>Save</strong>.</li>
<li>TexturePacker automatically adds the .<em>plist</em> extension to the Data File, but Unity wants the file to be .<em>xml</em>.  So in the text field, replace .<em>plist</em> with .<em>xml</em>.</li>
<li>The Texture File path should already be set to the same location as the .xml file except that it will have a .png extension so there&#8217;s nothing to do there.</li>
</ul>
<p>If you followed the steps above, then your settings in TexturePacker should look like this (click the image to see a larger version):</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-texturepacker-level.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-texturepacker-level-sm.png" alt="" title="2dGamePt2 TexturePacker Level Sprites" width="536" height="532" class="alignnone size-full wp-image-970" /></a></p>
<p>Now if you click the <strong>Publish</strong> icon in TexturePacker and then switch back to Unity, you should see a <strong>SpriteAtlases</strong> folder in the Project tab with the sprite atlas and a sprite data files inside.</p>
<p>We need to make a couple of changes to the sprite atlas in Unity so that it looks correct.</p>
<ul>
<li>Select the <em>level.png</em> file in the Project tab. In the Inspector change the <strong>Filter Mode</strong> to <strong>Point</strong>.</li>
<li>Click the <strong>Override for Web</strong> box, set the <strong>Format</strong> to <strong>Truecolor</strong> and then click <strong>Apply</strong>.</li>
</ul>
<h3>Making The Level Sprites</h3>
<p>Now it&#8217;s time to dig into Orthello and turn the atlas into sprites.</p>
<h4>The Sprite Container:</h4>
<ul>
<li>In the Unity Project tab, expand the Orthello folders: <em>Orthello &#8211;> Objects &#8211;> Sprites &#8211;> SpriteAtlas</em> and then drag the <strong>SpriteAtlas-Cocos2D</strong> object into the Hierarchy.</li>
<li>In the Hierarchy tab, expand the newly created <strong>OT</strong> object and then the <strong>Containers</strong> object and you will see your new container with a name something like &#8220;<em>Container (id=-6840)</em>&#8220;.  This is the Container that will hold all of our level sprites from the atlas we made so you can rename the Container to something obvious like &#8220;<em>level</em>&#8220;.</li>
<li>Drag the <em>level.png</em> from the Project, <strong>SpriteAtlases</strong> folder and drop it on the &#8220;OTSprite Atlas Cocos 2D&#8221; scripts <strong>Texture</strong> slot.</li>
<li>Drag the <em>level.xml</em> from the Project, <strong>SpriteAtlases</strong> folder and drop it on to the <strong>Atlas Data File</strong> slot.  Now if you drop down the little Atlas Data arrow, you should see that it&#8217;s populated with all the sprite atlas data that TexturePacker generated for us.</li>
</ul>
<h4>Making An Animated Brick Tile:</h4>
<p>The brick needs to have some animations on it that will play when it&#8217;s destroyed and when it regenerates so we need to make an Animation.</p>
<ul>
<li>Drag an <strong>Animation</strong> object from <em>Orthello &#8211;> Objects &#8211;> Sprites</em> into the Hierarchy.  This will add a new object under <em>OT &#8211;> Animations</em> named something like &#8220;<em>Animation (id=-4320)</em>&#8220;.  Rename this object to &#8220;<em>level anims</em>&#8220;.</li>
<li>With the new <strong>OTAnimation</strong> still selected, adjust the settings to match those in the following image. </li>
<li>Under <strong>Framesets</strong>, set the <strong>Size</strong> to <em>3</em></li>
<li>To populate the Container field, drag &#038; drop the &#8220;<em>level</em>&#8221; object from <em>OT &#8211;> Containers</em> on to the Container field.</li>
</ul>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-LevelAnimation.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-LevelAnimation.png" alt="" title="2dGamePt2-Level Animation Settings" width="448" height="553" class="alignnone size-full wp-image-975" /></a></p>
<ul>
<li>Next find the <strong>AnimatingSprite</strong> object in <em>Orthello &#8211;> Objects &#8211;> Sprites</em> and drag it into the Hierarchy, this will make a new object in the scene with a name like &#8220;<em>Animating Sprite (id=-23050)</em>&#8220;.  Rename this object &#8220;<em>brick</em>&#8220;.</li>
<li>With the new brick object still selected in the Hierarchy, drag the &#8220;<em>level anims</em>&#8221; object on to the <strong>Animation</strong> slot.  The <strong>Sprite Container</strong> slot should automatically fill with a reference to the &#8220;level&#8221; container object, if it doesn&#8217;t you can drag &#038; drop that onto the slot.</li>
</ul>
<p>Now you should see a brick sprite in your scene and if you press Play in Unity, the sprite will animate through all of the frames in the animation.  We don&#8217;t want the animation to play on start so uncheck the <strong>Play On Start</strong> checkbox.</p>
<h4>Adding Collision To The Brick:</h4>
<p>We&#8217;re going to need some collision on the brick later on so that the player knows when he/she&#8217;s standing on the ground.</p>
<ul>
<li>With the brick object still selected in the Hierarchy, check the <strong>Collidable</strong> checkbox.  This will automatically add a Box Collider and Rigidbody component to the sprite.</li>
<li>We also need to Tag the object with a specific tag and add it to a Layer.  Go to <em>Edit &#8211;> Project Settings &#8211;> Tags</em> to open the <strong>Tag Manager</strong>.</li>
<li>Under <strong>Tags</strong> at the very top, drop down the little arrow and then type &#8220;<em>Ground</em>&#8221; (without the quotes) into the <strong>Element0</strong> field and press enter.  We&#8217;re going to need a few more tags later on so while we&#8217;re here, add another tag called &#8220;<em>Ladder</em>&#8221; and &#8220;<em>Rope</em>&#8220;.</li>
<li>We need some <strong>Layers</strong> too so under <strong>User Layer 8</strong>, type <em>Ground</em> and under<strong> User Layer 9 </strong>type <em>Ladder</em>.</li>
<li>Click on the brick object in Hierarchy and the drop down the <strong>Tag</strong> list in the Inspector and select <em>Ground</em>.  Then click on the <strong>Layer</strong> drop down and select <em>Ground</em> from that list.</li>
</ul>
<h4>Turn It Into A Prefab:</h4>
<p>Later on in the tutorial series we&#8217;re going to be adding some stuff to the brick object and making some changes so it&#8217;s a good idea to turn the object into a Prefab so that if you build a level with the brick and then and then want to make changes to it later, the changes will be applied <em>all</em> the prefab brick objects in your level.  Making a prefab is super easy and will save you a ton of time later on.</p>
<ul>
<li>Create a new folder in your Project and name it &#8220;<em>Prefabs</em>&#8220;.</li>
<li>Drag the <em>brick</em> object from the Hierarchy and drop it into the <strong>Prefabs</strong> folder in the Project tab.</li>
</ul>
<h3>Making The Static Level Sprites</h3>
<p>Next we need to make the concrete, ladder and rope tiles.  We&#8217;re going to use the same Container for these that we made before but instead of displaying them with an AnimatedSprite, we&#8217;re going to use the Sprite object.</p>
<h4>Concrete Tile:</h4>
<ul>
<li>If your brick object is still sitting in the center of the Scene, move it to the side so it&#8217;s out of the way.</li>
<li>Drag &#038; drop the <strong>Sprite</strong> object from <em>Orthello &#8211;> Objects &#8211;> Sprites</em> into the Hierarchy or Scene which will create a new object named something like &#8220;<em>Sprite (id=-3700)</em>&#8220;.  Rename that object to &#8220;<em>concrete</em>&#8220;.</li>
<li>Drag the level object that we created earlier from <em>OT &#8211;> Containers</em> and drop it on to the <strong>Sprite Container</strong> slot in the Inspector.</li>
<li>Your sprite will appear but it looks like the brick sprite that we made before, that&#8217;s because the brick is the first texture on the Sprite Atlases index.  Click and hold your mouse over the word &#8220;<strong>Frame Index</strong>&#8221; in the inspector (with the concrete object selected) and then drag the mouse to the right to scroll through the textures on the sprite atlas.  The concrete texture is at index <strong>14</strong> so set it to that.  The sprite should now look like a solid brick.</li>
<li>Check the <strong>Collidable</strong> checkbox to add collision to the object.</li>
<li>Drop down the <strong>Tag</strong> list in the Inspector and select <em>Ground</em>.  Then click on the <strong>Layer</strong> drop down and select <em>Ground</em> from that list.</li>
<li>Drag the <em>concrete</em> object from the Hierarchy into the <strong>Prefabs</strong> folder in the Project tab to create prefab from the object.</li>
</ul>
<h4>Ladder and Rope Tiles:</h4>
<p>The Ladder and Rope tiles follow most of the same steps as the Concrete tile.</p>
<ul>
<li>Move concrete tile out of the way if it&#8217;s still sitting in the center or the Scene view.</li>
<li>Drag &#038; drop a <strong>Sprite</strong> object from <em>Orthello &#8211;> Objects &#8211;> Sprites</em> into the Hierarchy or Scene and rename the object to &#8220;<em>ladder</em>&#8220;.</li>
<li>Drag the <em>level</em> object that we created earlier from <em>OT &#8211;> Containers</em> and drop it on to the <strong>Sprite Container</strong> slot in the Inspector.</li>
<li>Change the <strong>Frame Index</strong> to <em>15</em>, the sprite in the Scene view should now look like a ladder segment.  That&#8217;s all we need to do on the ladder tile for now.</li>
<li>To make the Rope tile, duplicate the ladder sprite in the Hierarchy and then rename it &#8220;<em>rope</em>&#8220;.</li>
<li>Change the <strong>Frame Index</strong> to <em>17</em> so that it looks like a black cube with a white line across the top (that&#8217;s our rope tile!).</li>
<li>Now make prefabs from the ladder and rope by dragging each of the objects from the Hierarchy into the Prefabs folder in the Project tab.</li>
</ul>
<h3>Making The Bottom Border:</h3>
<p>Now we have all the sprites necessary for making levels, but before we start we need to make a border object that will sit at the bottom of the screen.  The border will give the player and enemies something to stand on if there are missing bricks along the bottom row and it will also give us something to snap to so that the levels will adhere to a nice grid.</p>
<ul>
<li>Go to <em>Game Object &#8211;> Create Other &#8211;> Cube</em> and rename it to &#8220;<em>border bottom</em>&#8220;</li>
<li>Change the Transform Position to X: 0, Y: -10.3, Z: 0</li>
<li>Change the Transform Scale to X: 26, Y: 1, Z: 1</li>
<li>Drag and drop the border bottom object from the Hierarchy into the Prefabs folder in the Project tab to turn it into a prefab.</li>
</ul>
<p>A small amount of the cube should be visible above the bottom of the Game view and it shouldn&#8217;t quite be all the way to each edge.  The cube is pretty ugly with the default white material, so let&#8217;s make a material that matches the color of the bricks.</p>
<ul>
<li>Create a new folder in the Project tab and name it <em>Materials</em>.</li>
<li>Right click on the <strong>Materials</strong> folder and go to <em>Create &#8211;> Material</em> and then rename the new material &#8220;<em>border</em>&#8220;</li>
<li>Select the <em>border</em> material and then in the Inspector click on the white area beside the little eye dropper icon, this will open up the color picker.</li>
<li>Change the RGBA settings to R: 159, G: 2, B: 0, A: 255 and then close the color picker.</li>
<li>Drag the <em>border</em> material and drop it on to the <em>border bottom</em> object in the Hierarchy to apply the material.  The border should now be the same color as the bricks.</li>
</ul>
<h3>Change The Background Color</h3>
<p>We&#8217;re almost ready to make a level, but first lets change the background color to black.</p>
<ul>
<li>Select the <strong>Main Camera</strong> and then click on the color swatch next to <strong>Background</strong>.</li>
<li>Change the RGBA settings to 0,0,0,255.  The background in the Game window should now be black.</li>
</ul>
<h3>Making A Level:</h3>
<p>Whew!  It took a few steps, but now you have everything you need to build a bunch of levels.  Well almost everything &#8211; you still need a player, enemies, a pickup and a few other things which we&#8217;re going to cover later on in the series.</p>
<p>At this point you can just start duplicating the brick, concrete, ladder and rope tiles around the scene to make a level.  BUT before you do, here are a few tips:</p>
<ul>
<li>In the Scene view, click on the drop down list directly under the Scene tab &#8211; it might say something like &#8220;Textured&#8221; and change the option to <em>Tex-Wire</em>.</li>
<li>You can use <a href="http://unity3d.com/support/documentation/Manual/Positioning%20GameObjects.html" title="Unity's vertex snapping docs">Vertex Snap</a> to easily align objects &#8211; in the Scene view hold down the V key and hover the mouse over any of the 4 corners on one of your tiles and you&#8217;ll see that the manipulator will snap to the closest corner.  Click the left mouse button when the handle is over a corner of the sprite that you want to snap from and then drag the object to another sprite corner to align it tightly with that tile.</li>
<li>Remember that bottom border cube we made before, well you can use that as a base line for snapping your cubes so that you can build the entire level on a grid.  Grab one of your tiles and snap the lower left corner to the upper corner of the bottom border object.  Note that you don&#8217;t have to worry about snapping on the Z axis since Orthello doesn&#8217;t allow you to move objects along the Z axis.</li>
<li>You can also select several tiles at the same time either with shift+left click or by dragging an area around a bunch of tiles.  Duplicate those tiles and then use Vertex Snap to snap them to other tiles in the scene.</li>
</ul>
<p>Here&#8217;s what my initial scene looks like as I start by building the level from the bottom border object (click to see a larger version):</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-InitialTilePlacement.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-InitialTilePlace-sm.png" alt="" title="2dGamePt2 Initial Tile Placement" width="536" height="582" class="alignnone size-full wp-image-984" /></a></p>
<p>And here&#8217;s what a finished level looks like (click to see a larger version):</p>
<p><a href="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-FinalLevel.png"><img src="http://www.rocket5studios.com/wp-content/uploads/2011/10/2dGamePt2-FinalLevel-sm.png" alt="" title="2dGamePt2 Final Level" width="536" height="377" class="alignnone size-full wp-image-986" /></a></p>
<h3>Conclusion:</h3>
<p>I hope you enjoyed this post and learned a little more about how to make 2D games with Unity.  In the next post we&#8217;re going to be adding a playable character so you can actually run around in the levels.</p>
<p>If you like this post, please be sure to say <em>hi</em> in the comments and follow me on <a href="http://twitter.com/rocket5studios" title="Rocket 5 on Twitter">Twitter</a> and <a href="http://www.facebook.com/rocket5studios" title="Rocket 5 on Facebook">Facebook</a>.  Your support helps to keep these tutorial coming. This blog post is part of <a href="http://idevblogaday.com/" title="iDevBlogADay">iDevBlogADay</a>, a collection of indie developers writing about their development experiences.</p>
<p><a href="http://www.rocket5studios.com/files/Rocket5_2DGame_blogPt2b.zip">Download the project up to this point</a>.</p>
<h3>Further Reading</h3>
<p><a href="http://www.rocket5studios.com/tutorials/make-a-2d-game-in-unity3d-using-only-free-tools-part-1/" title="Make A 2D Game in Unity3D Using Only Free Tools Part 1">Make A 2D Game in Unity3D Using Only Free Tools Part 1</a></p>
<p>My previous tutorial series that used Sprite Manager 2 for the sprite display and animation duties:</p>
<ul>
<li><a href="http://www.rocket5studios.com/tutorials/creating-2d-games-with-unity3d-part-1/" target="_blank">Creating 2D Games with Unity3D Part 1</a></li>
<li><a href="http://www.rocket5studios.com/tutorials/creating-2d-games-with-unity3d-part-2/" target="_blank">Creating 2D Games with Unity3D Part 2</a></li>
<li><a href="http://www.rocket5studios.com/tutorials/2d-or-not-2d-creating-2d-games-with-unity3d-part-3/" target="_blank">Creating 2D Games with Unity3D Part 3</a></li>
<li><a href="http://www.rocket5studios.com/tutorials/creating-2d-games-with-unity3d-part-5-complex-collision/" target="_blank">Creating 2D Games with Unity3D Part 5</a></li>
</ul>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;count=horizontal&amp;text=Make%20A%202D%20Game%20with%20Unity3D%20Using%20Only%20Free%20Tools%20Part%202" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;counturl=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;count=horizontal&amp;text=Make%20A%202D%20Game%20with%20Unity3D%20Using%20Only%20Free%20Tools%20Part%202" scrolling="no" style="border:none;overflow:hidden;width:130px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;size=medium&amp;count=true" scrolling="no" style="border:none;overflow:hidden;width:90px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.rocket5studios.com%2Ftutorials%2Fmake-a-2d-game-with-unity3d-using-only-free-tools-part-2%2F&amp;title=Make%20A%202D%20Game%20with%20Unity3D%20Using%20Only%20Free%20Tools%20Part%202" id="wpa2a_16"><img src="http://www.rocket5studios.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.rocket5studios.com/tutorials/make-a-2d-game-with-unity3d-using-only-free-tools-part-2/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

