[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.00,0:00:04.30,Default,,0000,0000,0000,,In Unity 4.3 we're launching our first set of 2D features. Dialogue: 0,0:00:04.30,0:00:06.30,Default,,0000,0000,0000,,To compliment this we have constructed a Dialogue: 0,0:00:06.30,0:00:08.30,Default,,0000,0000,0000,,demo project with these tools. Dialogue: 0,0:00:08.30,0:00:11.53,Default,,0000,0000,0000,,Our 2D platformer is nicknamed 'Tower Bridge Defence' Dialogue: 0,0:00:11.53,0:00:13.78,Default,,0000,0000,0000,,It depicts London's Tower Bridge in the midst Dialogue: 0,0:00:13.78,0:00:15.56,Default,,0000,0000,0000,,of an alien invasion. Dialogue: 0,0:00:15.56,0:00:17.96,Default,,0000,0000,0000,,It's a completely sprite-based, physics driven Dialogue: 0,0:00:17.96,0:00:20.22,Default,,0000,0000,0000,,2D sample level that we hope will help you Dialogue: 0,0:00:20.22,0:00:23.47,Default,,0000,0000,0000,,understand how 2D games are put together in Unity. Dialogue: 0,0:00:23.47,0:00:25.47,Default,,0000,0000,0000,,This video will discuss the background and Dialogue: 0,0:00:25.47,0:00:28.18,Default,,0000,0000,0000,,foreground construction, characters, effects, Dialogue: 0,0:00:28.18,0:00:30.18,Default,,0000,0000,0000,,camera tracking, animation and scripting Dialogue: 0,0:00:30.18,0:00:31.64,Default,,0000,0000,0000,,used in the demo. Dialogue: 0,0:00:31.64,0:00:33.64,Default,,0000,0000,0000,,To begin with, let's discuss the basics Dialogue: 0,0:00:33.65,0:00:36.14,Default,,0000,0000,0000,,of working in 2D in Unity. Dialogue: 0,0:00:36.86,0:00:39.29,Default,,0000,0000,0000,,Firstly, when working in 2D, you should set the Dialogue: 0,0:00:39.29,0:00:41.22,Default,,0000,0000,0000,,Editor Behaviour Mode to 2D Dialogue: 0,0:00:41.22,0:00:43.04,Default,,0000,0000,0000,,for various settings. Dialogue: 0,0:00:43.04,0:00:45.04,Default,,0000,0000,0000,,This can be done when making a new project Dialogue: 0,0:00:45.04,0:00:47.04,Default,,0000,0000,0000,,using the drop-down on the project wizard Dialogue: 0,0:00:47.04,0:00:49.54,Default,,0000,0000,0000,,or during a project by choosing Dialogue: 0,0:00:49.54,0:00:53.17,Default,,0000,0000,0000,,Edit - Project Settings - Editor from the top menu. Dialogue: 0,0:00:53.17,0:00:55.17,Default,,0000,0000,0000,,This means that by default textures Dialogue: 0,0:00:55.17,0:00:57.17,Default,,0000,0000,0000,,will be imported as sprites and the Dialogue: 0,0:00:57.17,0:00:59.63,Default,,0000,0000,0000,,Scene View will default to 2D mode. Dialogue: 0,0:00:59.63,0:01:01.63,Default,,0000,0000,0000,,This new mode gives you a completely orthographic Dialogue: 0,0:01:01.63,0:01:04.42,Default,,0000,0000,0000,,view in which to construct 2D games. Dialogue: 0,0:01:04.42,0:01:06.81,Default,,0000,0000,0000,,It also hides the usual 3D gizmo Dialogue: 0,0:01:06.81,0:01:09.20,Default,,0000,0000,0000,,in the top right of the view, giving you more space Dialogue: 0,0:01:09.20,0:01:11.94,Default,,0000,0000,0000,,to work in. Aside from these settings the work Dialogue: 0,0:01:11.94,0:01:14.24,Default,,0000,0000,0000,,flows for 2D have been designed to mirror Dialogue: 0,0:01:14.24,0:01:17.04,Default,,0000,0000,0000,,existing Unity approaches to 3D game creation. Dialogue: 0,0:01:17.04,0:01:19.04,Default,,0000,0000,0000,,So if you already know a little about Unity Dialogue: 0,0:01:19.04,0:01:21.04,Default,,0000,0000,0000,,you'll be in a great position to start making Dialogue: 0,0:01:21.04,0:01:22.93,Default,,0000,0000,0000,,2D games right away. Dialogue: 0,0:01:22.93,0:01:24.93,Default,,0000,0000,0000,,It's worth noting at this stage that you can Dialogue: 0,0:01:24.93,0:01:27.22,Default,,0000,0000,0000,,still mix 2D and 3D in Unity, Dialogue: 0,0:01:27.22,0:01:29.72,Default,,0000,0000,0000,,so if you want to add 3D elements to your 2D game Dialogue: 0,0:01:29.72,0:01:32.87,Default,,0000,0000,0000,,or vice versa you can do that with no worries. Dialogue: 0,0:01:33.37,0:01:35.50,Default,,0000,0000,0000,,Let's take a look at the demo project itself, Dialogue: 0,0:01:35.50,0:01:38.31,Default,,0000,0000,0000,,and how we built it up one stage at a time. Dialogue: 0,0:01:38.81,0:01:40.81,Default,,0000,0000,0000,,We began by sketching out the level design Dialogue: 0,0:01:40.81,0:01:42.81,Default,,0000,0000,0000,,for this sample level and then went about Dialogue: 0,0:01:42.81,0:01:44.81,Default,,0000,0000,0000,,recreating the layout in Photoshop. Dialogue: 0,0:01:45.31,0:01:47.31,Default,,0000,0000,0000,,Creating and exporting the layers, Dialogue: 0,0:01:47.31,0:01:49.31,Default,,0000,0000,0000,,we were able to import these in to Unity Dialogue: 0,0:01:49.31,0:01:51.31,Default,,0000,0000,0000,,using the new Sprite type. Dialogue: 0,0:01:58.37,0:02:01.31,Default,,0000,0000,0000,,In order to create parallaxing in our background later, Dialogue: 0,0:02:01.31,0:02:03.67,Default,,0000,0000,0000,,we kept some of the background elements separate Dialogue: 0,0:02:03.67,0:02:06.52,Default,,0000,0000,0000,,and placed them on to a Background Sorting Layer. Dialogue: 0,0:02:06.52,0:02:09.66,Default,,0000,0000,0000,,Yet another new feature of 2D development in Unity. Dialogue: 0,0:02:10.16,0:02:12.84,Default,,0000,0000,0000,,Having assigned all of our backgrounds to this layer, Dialogue: 0,0:02:12.84,0:02:15.16,Default,,0000,0000,0000,,we could then use the Order In Layer property Dialogue: 0,0:02:15.16,0:02:17.38,Default,,0000,0000,0000,,of the Sprite Renderer to sort them. Dialogue: 0,0:02:17.38,0:02:19.38,Default,,0000,0000,0000,,Once we were happy with their positions Dialogue: 0,0:02:19.38,0:02:21.38,Default,,0000,0000,0000,,we could lock the Background Sorting Layer Dialogue: 0,0:02:21.38,0:02:23.38,Default,,0000,0000,0000,,so that when we added foreground elements Dialogue: 0,0:02:23.38,0:02:25.38,Default,,0000,0000,0000,,we didn't need to worry about accidentally Dialogue: 0,0:02:25.38,0:02:27.75,Default,,0000,0000,0000,,dragging background elements around. Dialogue: 0,0:02:27.75,0:02:29.75,Default,,0000,0000,0000,,This is done using the Layers pull-down in the Dialogue: 0,0:02:29.75,0:02:31.75,Default,,0000,0000,0000,,top right of the interface. Dialogue: 0,0:02:32.82,0:02:35.53,Default,,0000,0000,0000,,Because the background elements are purely decorative Dialogue: 0,0:02:35.53,0:02:37.53,Default,,0000,0000,0000,,we did not require any additional components Dialogue: 0,0:02:37.53,0:02:39.53,Default,,0000,0000,0000,,on the sprite game object. Dialogue: 0,0:02:39.53,0:02:41.53,Default,,0000,0000,0000,,They were parented to an empty game object Dialogue: 0,0:02:41.53,0:02:44.20,Default,,0000,0000,0000,,that has a simple script to handle parallaxing Dialogue: 0,0:02:44.20,0:02:46.20,Default,,0000,0000,0000,,called BackgroundParallax. Dialogue: 0,0:02:46.20,0:02:48.64,Default,,0000,0000,0000,,For more information you'll find this script Dialogue: 0,0:02:48.64,0:02:50.64,Default,,0000,0000,0000,,fully commented in the Scripts folder. Dialogue: 0,0:02:54.91,0:02:56.91,Default,,0000,0000,0000,,Next up came the creation of the foreground elements Dialogue: 0,0:02:56.91,0:02:59.40,Default,,0000,0000,0000,,that our characters would actually traverse. Dialogue: 0,0:02:59.79,0:03:02.28,Default,,0000,0000,0000,,We designed London's Tower Bridge with a UFO Dialogue: 0,0:03:02.28,0:03:03.47,Default,,0000,0000,0000,,landed in the centre. Dialogue: 0,0:03:03.47,0:03:05.47,Default,,0000,0000,0000,,The character has the run of the environment Dialogue: 0,0:03:05.47,0:03:07.47,Default,,0000,0000,0000,,as enemies spawn from the skies and begin Dialogue: 0,0:03:07.47,0:03:09.22,Default,,0000,0000,0000,,to navigate around the level. Dialogue: 0,0:03:09.22,0:03:11.22,Default,,0000,0000,0000,,As such, each piece of the foreground required Dialogue: 0,0:03:11.22,0:03:13.63,Default,,0000,0000,0000,,a collider for characters to walk upon. Dialogue: 0,0:03:13.63,0:03:15.63,Default,,0000,0000,0000,,For most of the environment we used 2D Dialogue: 0,0:03:15.63,0:03:17.63,Default,,0000,0000,0000,,box colliders for efficiency, Dialogue: 0,0:03:17.63,0:03:21.24,Default,,0000,0000,0000,,but the UFO itself has a more complex shape. Dialogue: 0,0:03:22.50,0:03:24.50,Default,,0000,0000,0000,,Unity's Polygon Collider allowed us to Dialogue: 0,0:03:24.50,0:03:26.88,Default,,0000,0000,0000,,automate creation of the collider itself Dialogue: 0,0:03:26.88,0:03:28.72,Default,,0000,0000,0000,,based on the shape of the sprite. Dialogue: 0,0:03:28.72,0:03:30.72,Default,,0000,0000,0000,,It even meant that we could tweak the shape of Dialogue: 0,0:03:30.72,0:03:32.05,Default,,0000,0000,0000,,the collider later. Dialogue: 0,0:03:32.05,0:03:34.16,Default,,0000,0000,0000,,Moving, adding or subtracting points Dialogue: 0,0:03:34.16,0:03:36.16,Default,,0000,0000,0000,,of the collider shape to make it more Dialogue: 0,0:03:36.16,0:03:38.16,Default,,0000,0000,0000,,appropriate to walk over. Dialogue: 0,0:03:38.66,0:03:40.66,Default,,0000,0000,0000,,To sort these foregrounds we created a Dialogue: 0,0:03:40.66,0:03:43.15,Default,,0000,0000,0000,,Foregrounds Sorting Layer, which was drawn Dialogue: 0,0:03:43.15,0:03:45.60,Default,,0000,0000,0000,,above the backgrounds in the Tags And Layers manager. Dialogue: 0,0:03:48.88,0:03:50.88,Default,,0000,0000,0000,,Next, let's take a look at our hero. Dialogue: 0,0:03:53.71,0:03:55.60,Default,,0000,0000,0000,,Our player character was yet again designed Dialogue: 0,0:03:55.60,0:03:57.60,Default,,0000,0000,0000,,in Photoshop, and for this demo Dialogue: 0,0:03:57.60,0:03:59.60,Default,,0000,0000,0000,,we chose to make a character with independent Dialogue: 0,0:03:59.60,0:04:01.60,Default,,0000,0000,0000,,limbs and features in the style of Dialogue: 0,0:04:01.60,0:04:03.60,Default,,0000,0000,0000,,2D hits such as Rayman. Dialogue: 0,0:04:03.60,0:04:05.60,Default,,0000,0000,0000,,Our other option would have been to design Dialogue: 0,0:04:05.60,0:04:08.14,Default,,0000,0000,0000,,a sprite sheet-based animation and design each Dialogue: 0,0:04:08.14,0:04:09.64,Default,,0000,0000,0000,,each frame in Photoshop, Dialogue: 0,0:04:09.64,0:04:12.36,Default,,0000,0000,0000,,an approach we use later for the background Swan, Dialogue: 0,0:04:12.36,0:04:14.36,Default,,0000,0000,0000,,which we'll discuss later in the video. Dialogue: 0,0:04:15.07,0:04:17.07,Default,,0000,0000,0000,,Because our character had independent elements Dialogue: 0,0:04:17.07,0:04:20.20,Default,,0000,0000,0000,,that we wish to animate we finalised the design Dialogue: 0,0:04:20.20,0:04:22.20,Default,,0000,0000,0000,,and then moved his bodily elements in to separate Dialogue: 0,0:04:22.20,0:04:25.41,Default,,0000,0000,0000,,spaces on our canvas to allow Unity to isolate them Dialogue: 0,0:04:25.41,0:04:27.96,Default,,0000,0000,0000,,as separate sprites in the Importer. Dialogue: 0,0:04:28.76,0:04:30.76,Default,,0000,0000,0000,,This meant that we could then arrange all of Dialogue: 0,0:04:30.76,0:04:33.10,Default,,0000,0000,0000,,our sprites as separate elements to be animated. Dialogue: 0,0:04:33.10,0:04:35.50,Default,,0000,0000,0000,,We placed these on to a new Character Sorting Layer Dialogue: 0,0:04:35.50,0:04:38.17,Default,,0000,0000,0000,,that we created, and then used Z values in the Dialogue: 0,0:04:38.17,0:04:40.92,Default,,0000,0000,0000,,transform to sort their rendering depth. Dialogue: 0,0:04:48.81,0:04:50.81,Default,,0000,0000,0000,,All of these sprites are then arranged under an Dialogue: 0,0:04:50.81,0:04:52.81,Default,,0000,0000,0000,,empty game object, which has all of our Dialogue: 0,0:04:52.81,0:04:56.59,Default,,0000,0000,0000,,controls scripting, colliders, physics, excetera attached to it. Dialogue: 0,0:04:56.59,0:04:58.59,Default,,0000,0000,0000,,Once we'd done this we were able to use the newly Dialogue: 0,0:04:58.59,0:05:01.04,Default,,0000,0000,0000,,upgraded Animation window to create Dialogue: 0,0:05:01.04,0:05:03.91,Default,,0000,0000,0000,,Idle, Run, Jump, Shoot and Death animations Dialogue: 0,0:05:03.91,0:05:07.10,Default,,0000,0000,0000,,by animating each of the character's sprites over time. Dialogue: 0,0:05:07.10,0:05:09.80,Default,,0000,0000,0000,,With the new Dopesheet View in the Animation window Dialogue: 0,0:05:09.80,0:05:11.80,Default,,0000,0000,0000,,this is easier than ever. Dialogue: 0,0:05:13.41,0:05:16.01,Default,,0000,0000,0000,,We simply add animation to the parent object Dialogue: 0,0:05:16.01,0:05:19.40,Default,,0000,0000,0000,,and then create keyframes for any of the child objects. Dialogue: 0,0:05:19.40,0:05:21.40,Default,,0000,0000,0000,,Moving the playhead to where we want Dialogue: 0,0:05:21.40,0:05:23.40,Default,,0000,0000,0000,,and then moving the various parts of the character Dialogue: 0,0:05:23.40,0:05:25.40,Default,,0000,0000,0000,,to automatically keyframe the animation. Dialogue: 0,0:05:27.31,0:05:29.64,Default,,0000,0000,0000,,The ability to switch between Curve and Dopesheet Dialogue: 0,0:05:29.64,0:05:32.45,Default,,0000,0000,0000,,representation of our animation makes it easier than Dialogue: 0,0:05:32.45,0:05:35.06,Default,,0000,0000,0000,,ever to adjust timing and design. Dialogue: 0,0:05:36.73,0:05:38.73,Default,,0000,0000,0000,,With these animations created we can Dialogue: 0,0:05:38.73,0:05:41.37,Default,,0000,0000,0000,,then design a state machine for our character Dialogue: 0,0:05:41.37,0:05:43.80,Default,,0000,0000,0000,,so that when called upon in code, differing animations Dialogue: 0,0:05:43.80,0:05:45.28,Default,,0000,0000,0000,,could be played. Dialogue: 0,0:05:45.28,0:05:47.28,Default,,0000,0000,0000,,the animator controller for the character is Dialogue: 0,0:05:47.28,0:05:50.57,Default,,0000,0000,0000,,not driving a 3D biped, so we simply deselect Dialogue: 0,0:05:50.57,0:05:53.67,Default,,0000,0000,0000,,Apply Root Motion and select Animate Physics Dialogue: 0,0:05:53.67,0:05:55.67,Default,,0000,0000,0000,,in order to drive our animations in time with Dialogue: 0,0:05:55.67,0:05:57.29,Default,,0000,0000,0000,,the physics engine. Dialogue: 0,0:05:57.29,0:05:59.86,Default,,0000,0000,0000,,In order to traverse the environment our hero has a Dialogue: 0,0:05:59.86,0:06:02.23,Default,,0000,0000,0000,,circle collider at his feet and a box collider Dialogue: 0,0:06:02.23,0:06:04.56,Default,,0000,0000,0000,,to cover the rest of his body outline. Dialogue: 0,0:06:04.56,0:06:07.07,Default,,0000,0000,0000,,This means he can smoothly walk up and down hills Dialogue: 0,0:06:07.07,0:06:09.45,Default,,0000,0000,0000,,and when he jumps his head will hit the ceiling. Dialogue: 0,0:06:09.80,0:06:12.54,Default,,0000,0000,0000,,In order to control the character and it's animations Dialogue: 0,0:06:12.54,0:06:16.04,Default,,0000,0000,0000,,we wrote a script that moves him via 2D physics forces. Dialogue: 0,0:06:16.04,0:06:18.04,Default,,0000,0000,0000,,This means that we can apply physics to him Dialogue: 0,0:06:18.04,0:06:20.04,Default,,0000,0000,0000,,and the enemies during the game for more Dialogue: 0,0:06:20.04,0:06:21.43,Default,,0000,0000,0000,,dynamic game play. Dialogue: 0,0:06:21.43,0:06:23.81,Default,,0000,0000,0000,,In our PlayerControl script for the character Dialogue: 0,0:06:23.81,0:06:25.81,Default,,0000,0000,0000,,we check for player input. Dialogue: 0,0:06:25.81,0:06:27.81,Default,,0000,0000,0000,,We use this to apply physics forces Dialogue: 0,0:06:27.81,0:06:30.77,Default,,0000,0000,0000,,for movement and also send the value of the input Dialogue: 0,0:06:30.77,0:06:33.49,Default,,0000,0000,0000,,to the animator, which in turn defines which Dialogue: 0,0:06:33.49,0:06:36.48,Default,,0000,0000,0000,,animation should be playing and smoothly transitions Dialogue: 0,0:06:36.48,0:06:38.48,Default,,0000,0000,0000,,between the different animation clips that Dialogue: 0,0:06:38.48,0:06:40.48,Default,,0000,0000,0000,,we've created as states. Dialogue: 0,0:06:40.48,0:06:42.48,Default,,0000,0000,0000,,The great thing about using the animator to Dialogue: 0,0:06:42.48,0:06:44.48,Default,,0000,0000,0000,,create states from animation clips is Dialogue: 0,0:06:44.48,0:06:46.86,Default,,0000,0000,0000,,that we can go and tweak speeds of animation Dialogue: 0,0:06:46.86,0:06:48.86,Default,,0000,0000,0000,,to match our physics velocities Dialogue: 0,0:06:48.86,0:06:51.28,Default,,0000,0000,0000,,without having to reanimate anything Dialogue: 0,0:07:23.13,0:07:25.13,Default,,0000,0000,0000,,The FixedUpdate function evaluates with Dialogue: 0,0:07:25.13,0:07:27.59,Default,,0000,0000,0000,,each physics step, and the first thing we Dialogue: 0,0:07:27.59,0:07:29.59,Default,,0000,0000,0000,,do with this is to feed the value of Horizontal Dialogue: 0,0:07:29.59,0:07:32.99,Default,,0000,0000,0000,,input in to the Speed parameter of our animator. Dialogue: 0,0:07:33.95,0:07:35.95,Default,,0000,0000,0000,,The transition between Idle and Run Dialogue: 0,0:07:35.95,0:07:37.95,Default,,0000,0000,0000,,in our simple state machine requires Dialogue: 0,0:07:37.95,0:07:41.72,Default,,0000,0000,0000,,that the Speed parameter is above 0.1. Dialogue: 0,0:07:41.72,0:07:44.02,Default,,0000,0000,0000,,When it is, the animator blends from Idle Dialogue: 0,0:07:44.02,0:07:46.02,Default,,0000,0000,0000,,in to the Run state. Dialogue: 0,0:07:51.86,0:07:53.86,Default,,0000,0000,0000,,We then go on to add forces to the player's Dialogue: 0,0:07:53.86,0:07:57.18,Default,,0000,0000,0000,,2D physics component, the rigidbody2D, Dialogue: 0,0:07:57.18,0:07:58.82,Default,,0000,0000,0000,,in order to move him around. Dialogue: 0,0:07:59.63,0:08:02.52,Default,,0000,0000,0000,,We also handle which direction the character is facing Dialogue: 0,0:08:02.52,0:08:04.70,Default,,0000,0000,0000,,based on the value of Horizontal input, Dialogue: 0,0:08:04.70,0:08:07.71,Default,,0000,0000,0000,,checking whether it is above or below 0. Dialogue: 0,0:08:07.71,0:08:10.56,Default,,0000,0000,0000,,This is because in Unity, holding the left input key Dialogue: 0,0:08:10.56,0:08:14.57,Default,,0000,0000,0000,,returns a value of -1, where right returns positive 1. Dialogue: 0,0:08:15.07,0:08:18.70,Default,,0000,0000,0000,,Depending on input, we then call a simple flip function, Dialogue: 0,0:08:18.70,0:08:21.48,Default,,0000,0000,0000,,which reverses the X scale of the character, Dialogue: 0,0:08:21.48,0:08:24.57,Default,,0000,0000,0000,,giving him the appearance of facing the opposite direction. Dialogue: 0,0:08:26.85,0:08:28.85,Default,,0000,0000,0000,,To decide whether the player is grounded Dialogue: 0,0:08:28.85,0:08:31.60,Default,,0000,0000,0000,,we added a layer in Unity called Ground Dialogue: 0,0:08:31.60,0:08:34.98,Default,,0000,0000,0000,,and applied it to all of our walkable foreground surfaces. Dialogue: 0,0:08:43.40,0:08:45.97,Default,,0000,0000,0000,,We then used the Linecast function in 2D Dialogue: 0,0:08:45.97,0:08:47.97,Default,,0000,0000,0000,,to check whether something on the Ground layer Dialogue: 0,0:08:47.97,0:08:50.23,Default,,0000,0000,0000,,is below the character's feet. Dialogue: 0,0:08:50.23,0:08:52.78,Default,,0000,0000,0000,,To customise this more easily we created Dialogue: 0,0:08:52.78,0:08:54.78,Default,,0000,0000,0000,,an empty game object to use as a point Dialogue: 0,0:08:54.78,0:08:56.78,Default,,0000,0000,0000,,at which to check for the ground. Dialogue: 0,0:08:56.78,0:08:59.08,Default,,0000,0000,0000,,By adding a gizmo to this empty object Dialogue: 0,0:08:59.08,0:09:01.08,Default,,0000,0000,0000,,we are able to manipulate how far below Dialogue: 0,0:09:01.08,0:09:03.08,Default,,0000,0000,0000,,the character we'll check for the ground. Dialogue: 0,0:09:03.08,0:09:05.49,Default,,0000,0000,0000,,From a gameplay perspective this means that Dialogue: 0,0:09:05.49,0:09:07.96,Default,,0000,0000,0000,,the character can only jump when grounded. Dialogue: 0,0:09:08.46,0:09:10.46,Default,,0000,0000,0000,,Check out the rest of the comments in the script for more Dialogue: 0,0:09:10.46,0:09:12.65,Default,,0000,0000,0000,,information on the control of the player. Dialogue: 0,0:09:12.65,0:09:14.65,Default,,0000,0000,0000,,We will discuss the player's weapon Dialogue: 0,0:09:14.65,0:09:15.88,Default,,0000,0000,0000,,later in this video. Dialogue: 0,0:09:15.88,0:09:17.88,Default,,0000,0000,0000,,Next, let's take a look at how the camera Dialogue: 0,0:09:17.88,0:09:19.88,Default,,0000,0000,0000,,tracks the player in our demo. Dialogue: 0,0:09:21.29,0:09:24.35,Default,,0000,0000,0000,,In 2D games, much like 3D, the motion of Dialogue: 0,0:09:24.35,0:09:26.35,Default,,0000,0000,0000,,the camera tracking the action can make Dialogue: 0,0:09:26.35,0:09:27.82,Default,,0000,0000,0000,,or break your game. Dialogue: 0,0:09:27.82,0:09:30.58,Default,,0000,0000,0000,,For a classic 2D platformer, we looked at the mechanics Dialogue: 0,0:09:30.58,0:09:33.62,Default,,0000,0000,0000,,of one of the most interesting camera in 2D gaming history, Dialogue: 0,0:09:33.62,0:09:36.65,Default,,0000,0000,0000,,the camera from Super Mario World on the Super Nintendo Dialogue: 0,0:09:36.65,0:09:38.65,Default,,0000,0000,0000,,or Super Famicom. Dialogue: 0,0:09:38.65,0:09:40.65,Default,,0000,0000,0000,,In Super Mario world the camera tracks Dialogue: 0,0:09:40.65,0:09:42.65,Default,,0000,0000,0000,,horizontally, but uses a dead zone Dialogue: 0,0:09:42.65,0:09:45.12,Default,,0000,0000,0000,,or margin in the centre of the viewport Dialogue: 0,0:09:45.12,0:09:47.12,Default,,0000,0000,0000,,in which the character can move a little Dialogue: 0,0:09:47.12,0:09:49.34,Default,,0000,0000,0000,,without the camera tracking. Dialogue: 0,0:09:49.34,0:09:51.64,Default,,0000,0000,0000,,Once the character moved beyond this margin Dialogue: 0,0:09:51.64,0:09:54.05,Default,,0000,0000,0000,,the camera tracks back toward the player. Dialogue: 0,0:09:54.05,0:09:56.87,Default,,0000,0000,0000,,The Super Mario World camera used particular heights Dialogue: 0,0:09:56.87,0:09:59.54,Default,,0000,0000,0000,,to snap to vertically, but we didn't need this Dialogue: 0,0:09:59.54,0:10:01.54,Default,,0000,0000,0000,,kind of detail for our game as we Dialogue: 0,0:10:01.54,0:10:03.88,Default,,0000,0000,0000,,do not have a long level in the X axis Dialogue: 0,0:10:03.88,0:10:06.85,Default,,0000,0000,0000,,but more of a stage on which the action takes place. Dialogue: 0,0:10:07.21,0:10:09.21,Default,,0000,0000,0000,,For this reason our camera employs Dialogue: 0,0:10:09.21,0:10:12.79,Default,,0000,0000,0000,,similar tracking vertically as it does horizontally. Dialogue: 0,0:10:18.78,0:10:20.78,Default,,0000,0000,0000,,Take a look at the CameraFollow script on the Dialogue: 0,0:10:20.78,0:10:23.14,Default,,0000,0000,0000,,mainCamera game object to see comments Dialogue: 0,0:10:23.14,0:10:25.14,Default,,0000,0000,0000,,on how it achieves this effect. Dialogue: 0,0:10:26.14,0:10:27.84,Default,,0000,0000,0000,,There are several effects in the game, Dialogue: 0,0:10:27.84,0:10:29.84,Default,,0000,0000,0000,,but most important is our heroes ability Dialogue: 0,0:10:29.84,0:10:32.73,Default,,0000,0000,0000,,to slay the alien onslaught he's faced with. Dialogue: 0,0:10:32.73,0:10:36.34,Default,,0000,0000,0000,,Our hero shoots a bazooka which has animated recoil. Dialogue: 0,0:10:36.34,0:10:38.90,Default,,0000,0000,0000,,This action is made up of several parts. Dialogue: 0,0:10:38.90,0:10:41.64,Default,,0000,0000,0000,,First we listen for key input and when the Fire key is Dialogue: 0,0:10:41.64,0:10:43.96,Default,,0000,0000,0000,,pressed we instantiate a rocket, Dialogue: 0,0:10:43.96,0:10:47.97,Default,,0000,0000,0000,,play an audio clip and trigger an animation state to play. Dialogue: 0,0:10:47.97,0:10:49.97,Default,,0000,0000,0000,,Let's break this down even further. Dialogue: 0,0:10:49.97,0:10:52.42,Default,,0000,0000,0000,,in order to play the Shoot animation while other Dialogue: 0,0:10:52.42,0:10:54.42,Default,,0000,0000,0000,,animations such as Run are playing we Dialogue: 0,0:10:54.42,0:10:56.42,Default,,0000,0000,0000,,created a separate layer within our animator Dialogue: 0,0:10:56.42,0:10:57.68,Default,,0000,0000,0000,,called Shooting. Dialogue: 0,0:10:57.68,0:10:59.68,Default,,0000,0000,0000,,By setting the Weight property to 1 here Dialogue: 0,0:10:59.68,0:11:02.53,Default,,0000,0000,0000,,we can totally override motion in the base layer Dialogue: 0,0:11:02.53,0:11:04.53,Default,,0000,0000,0000,,on any parts of our character that are animated Dialogue: 0,0:11:04.53,0:11:06.98,Default,,0000,0000,0000,,by clips on the shooting layer. Dialogue: 0,0:11:20.50,0:11:22.50,Default,,0000,0000,0000,,In this layer we switch to the Shoot animation Dialogue: 0,0:11:22.50,0:11:25.35,Default,,0000,0000,0000,,from any state, when the Shoot trigger Dialogue: 0,0:11:25.35,0:11:27.35,Default,,0000,0000,0000,,parameter is called from code. Dialogue: 0,0:11:27.35,0:11:30.54,Default,,0000,0000,0000,,Let's take a look at the Gun script in charge of this. Dialogue: 0,0:11:32.70,0:11:35.14,Default,,0000,0000,0000,,Here you can see that we address the animator Dialogue: 0,0:11:35.14,0:11:37.40,Default,,0000,0000,0000,,and set that trigger to True. Dialogue: 0,0:11:37.40,0:11:40.51,Default,,0000,0000,0000,,Triggers simply act as a switch and reset themselves to false Dialogue: 0,0:11:40.51,0:11:43.25,Default,,0000,0000,0000,,on the next frame so that they can be called again, Dialogue: 0,0:11:43.25,0:11:45.51,Default,,0000,0000,0000,,which is perfect for actions such as shooting. Dialogue: 0,0:11:46.01,0:11:48.67,Default,,0000,0000,0000,,In addition to setting the animation we fire the Dialogue: 0,0:11:48.67,0:11:50.67,Default,,0000,0000,0000,,rockets themselves from this script, Dialogue: 0,0:11:50.67,0:11:52.67,Default,,0000,0000,0000,,playing an audio clip and dependent upon Dialogue: 0,0:11:52.67,0:11:54.67,Default,,0000,0000,0000,,the direction that the player is facing Dialogue: 0,0:11:54.67,0:11:57.78,Default,,0000,0000,0000,,we instantiate a rocket and give it a velocity Dialogue: 0,0:11:57.78,0:12:00.56,Default,,0000,0000,0000,,that's positive or negative in the X axis. Dialogue: 0,0:12:01.28,0:12:03.93,Default,,0000,0000,0000,,This script is attached to the Gun empty game object Dialogue: 0,0:12:03.93,0:12:05.29,Default,,0000,0000,0000,,in the hero's hierarchy. Dialogue: 0,0:12:05.29,0:12:08.08,Default,,0000,0000,0000,,We place code like this on to an empty game object Dialogue: 0,0:12:08.08,0:12:10.08,Default,,0000,0000,0000,,as it allows us to easily position Dialogue: 0,0:12:10.08,0:12:11.66,Default,,0000,0000,0000,,where the rockets are created. Dialogue: 0,0:12:11.66,0:12:13.66,Default,,0000,0000,0000,,We do this by placing the empty object Dialogue: 0,0:12:13.66,0:12:16.01,Default,,0000,0000,0000,,at the end of the barrel of the bazooka Dialogue: 0,0:12:16.01,0:12:18.01,Default,,0000,0000,0000,,and then we use it's own position as the Dialogue: 0,0:12:18.01,0:12:20.01,Default,,0000,0000,0000,,point at which to spawn the rockets. Dialogue: 0,0:12:40.25,0:12:42.80,Default,,0000,0000,0000,,The rocket itself has a 2D rigidbody Dialogue: 0,0:12:42.80,0:12:44.80,Default,,0000,0000,0000,,and we assign a velocity to that in order Dialogue: 0,0:12:44.80,0:12:46.80,Default,,0000,0000,0000,,to make it move. Dialogue: 0,0:12:46.80,0:12:49.10,Default,,0000,0000,0000,,It has a sprite swap flame exhaust Dialogue: 0,0:12:49.10,0:12:51.10,Default,,0000,0000,0000,,plus a particle system for smoke. Dialogue: 0,0:12:52.83,0:12:56.48,Default,,0000,0000,0000,,The particle system also accepts the new sprite type of graphics Dialogue: 0,0:12:56.48,0:12:58.48,Default,,0000,0000,0000,,so by adding a sprite sheet of smoke puffs Dialogue: 0,0:12:58.48,0:13:00.48,Default,,0000,0000,0000,,to a material we can assign it to the Dialogue: 0,0:13:00.48,0:13:04.15,Default,,0000,0000,0000,,texture sheet animation module of the particle system Dialogue: 0,0:13:04.15,0:13:06.23,Default,,0000,0000,0000,,and we get instant animation of our Dialogue: 0,0:13:06.23,0:13:08.23,Default,,0000,0000,0000,,sprites for the particle emission. Dialogue: 0,0:13:16.12,0:13:18.94,Default,,0000,0000,0000,,When our rockets hit an enemy or part of the environment Dialogue: 0,0:13:18.94,0:13:20.94,Default,,0000,0000,0000,,the rocket itself is destroyed and Dialogue: 0,0:13:20.94,0:13:22.94,Default,,0000,0000,0000,,an explosion is spawned. Dialogue: 0,0:13:22.94,0:13:24.94,Default,,0000,0000,0000,,The explosion is simply a sprite game object Dialogue: 0,0:13:24.94,0:13:27.73,Default,,0000,0000,0000,,that animates through a sprite sheet that we have created. Dialogue: 0,0:13:27.73,0:13:30.31,Default,,0000,0000,0000,,Yet again using sorting layers to render this Dialogue: 0,0:13:30.31,0:13:33.70,Default,,0000,0000,0000,,at the lowest layer order of our foreground objects. Dialogue: 0,0:13:36.17,0:13:38.17,Default,,0000,0000,0000,,When adding sprite-based animation like this Dialogue: 0,0:13:38.17,0:13:40.17,Default,,0000,0000,0000,,we setup the sprites themselves by Dialogue: 0,0:13:40.17,0:13:42.17,Default,,0000,0000,0000,,selecting the file in our Project Panel Dialogue: 0,0:13:42.17,0:13:44.58,Default,,0000,0000,0000,,and choosing the Sprite Mode Multiple. Dialogue: 0,0:13:44.58,0:13:46.58,Default,,0000,0000,0000,,This gives us access to the sprite editor Dialogue: 0,0:13:46.58,0:13:49.76,Default,,0000,0000,0000,,which allows us to slice manually or automatically. Dialogue: 0,0:13:49.76,0:13:52.41,Default,,0000,0000,0000,,Once happy with the selection of sprites from our file Dialogue: 0,0:13:52.41,0:13:54.41,Default,,0000,0000,0000,,we simply hit Apply and Unity Dialogue: 0,0:13:54.41,0:13:56.76,Default,,0000,0000,0000,,generates the sprites as children of that file Dialogue: 0,0:13:56.76,0:13:58.76,Default,,0000,0000,0000,,to be used in our project. Dialogue: 0,0:13:59.71,0:14:01.69,Default,,0000,0000,0000,,So that's our rocket in a nutshell. Dialogue: 0,0:14:01.69,0:14:03.69,Default,,0000,0000,0000,,We will discuss the mechanics of killing the enemies Dialogue: 0,0:14:03.69,0:14:06.53,Default,,0000,0000,0000,,later in this video in the section about enemies. Dialogue: 0,0:14:07.10,0:14:09.45,Default,,0000,0000,0000,,Let's return to the player character now and look at Dialogue: 0,0:14:09.45,0:14:12.19,Default,,0000,0000,0000,,how we handle health and taking damage. Dialogue: 0,0:14:12.19,0:14:14.19,Default,,0000,0000,0000,,Health is stored as a float and Dialogue: 0,0:14:14.19,0:14:16.19,Default,,0000,0000,0000,,with each interaction with a tagged enemy Dialogue: 0,0:14:16.19,0:14:18.55,Default,,0000,0000,0000,,we call the TakeDamage function. Dialogue: 0,0:14:18.55,0:14:20.55,Default,,0000,0000,0000,,This is only allowed to occur after the Dialogue: 0,0:14:20.55,0:14:22.55,Default,,0000,0000,0000,,repeatDamagePeriod has passed Dialogue: 0,0:14:22.55,0:14:25.35,Default,,0000,0000,0000,,to avoid the player being killed very quickly. Dialogue: 0,0:14:26.52,0:14:29.14,Default,,0000,0000,0000,,To allow the player to escape enemies more easily Dialogue: 0,0:14:29.14,0:14:31.14,Default,,0000,0000,0000,,and to show the player that they are being hurt Dialogue: 0,0:14:31.14,0:14:33.14,Default,,0000,0000,0000,,we make the act of taking damage Dialogue: 0,0:14:33.14,0:14:34.85,Default,,0000,0000,0000,,repel the character physically. Dialogue: 0,0:14:34.85,0:14:37.54,Default,,0000,0000,0000,,To achieve this the TakeDamage function briefly Dialogue: 0,0:14:37.54,0:14:39.54,Default,,0000,0000,0000,,stops the player from jumping Dialogue: 0,0:14:39.54,0:14:42.12,Default,,0000,0000,0000,,and finds a vector from the enemy to the player Dialogue: 0,0:14:42.12,0:14:44.12,Default,,0000,0000,0000,,and repels him in that direction Dialogue: 0,0:14:44.12,0:14:46.12,Default,,0000,0000,0000,,by adding a physics force. Dialogue: 0,0:14:46.12,0:14:48.68,Default,,0000,0000,0000,,The hurtForce variable is exposed in the Inspector Dialogue: 0,0:14:48.68,0:14:51.32,Default,,0000,0000,0000,,as public so that it can be tweaked Dialogue: 0,0:14:51.32,0:14:53.32,Default,,0000,0000,0000,,to adjust this element of game play without Dialogue: 0,0:14:53.32,0:14:55.32,Default,,0000,0000,0000,,returning to the script. Dialogue: 0,0:14:55.32,0:14:57.32,Default,,0000,0000,0000,,In addition to repelling the player, Dialogue: 0,0:14:57.32,0:14:59.81,Default,,0000,0000,0000,,we of course subtract from the player's health. Dialogue: 0,0:14:59.81,0:15:02.21,Default,,0000,0000,0000,,and update the player's health bar. Dialogue: 0,0:15:02.21,0:15:04.62,Default,,0000,0000,0000,,To signify the decrease in health we subtract Dialogue: 0,0:15:04.62,0:15:06.88,Default,,0000,0000,0000,,from the width of the bar and use a colour lerp Dialogue: 0,0:15:06.88,0:15:09.82,Default,,0000,0000,0000,,to transition it's colour between green and red, Dialogue: 0,0:15:09.82,0:15:12.64,Default,,0000,0000,0000,,both by finding the percentage that the current health is Dialogue: 0,0:15:12.64,0:15:14.64,Default,,0000,0000,0000,,of the full health amount. Dialogue: 0,0:15:14.64,0:15:17.87,Default,,0000,0000,0000,,The health bar simply comprises of two sprites, Dialogue: 0,0:15:17.87,0:15:19.96,Default,,0000,0000,0000,,one for the outline of the bar and the other Dialogue: 0,0:15:19.96,0:15:21.74,Default,,0000,0000,0000,,for the bar itself. Dialogue: 0,0:15:21.74,0:15:23.74,Default,,0000,0000,0000,,This was again designed in Photoshop and then Dialogue: 0,0:15:23.74,0:15:25.95,Default,,0000,0000,0000,,the two separate elements were exported. Dialogue: 0,0:15:25.95,0:15:27.95,Default,,0000,0000,0000,,In the import settings for these sprites Dialogue: 0,0:15:27.95,0:15:30.47,Default,,0000,0000,0000,,we set their pivot to the middle left of the graphic Dialogue: 0,0:15:30.47,0:15:34.05,Default,,0000,0000,0000,,so that when it scales down it shrinks towards the left. Dialogue: 0,0:15:48.57,0:15:50.57,Default,,0000,0000,0000,,These two sprites are placed under an empty Dialogue: 0,0:15:50.57,0:15:52.57,Default,,0000,0000,0000,,parent game object which has a simple script Dialogue: 0,0:15:52.57,0:15:54.57,Default,,0000,0000,0000,,on it which makes it follow the player. Dialogue: 0,0:15:54.57,0:15:56.62,Default,,0000,0000,0000,,We do this by setting the position to the Dialogue: 0,0:15:56.62,0:15:58.62,Default,,0000,0000,0000,,same as the player object's position Dialogue: 0,0:15:58.62,0:16:00.62,Default,,0000,0000,0000,,plus an offset that we've made public to allow Dialogue: 0,0:16:00.62,0:16:02.62,Default,,0000,0000,0000,,for adjustment in the Inspector. Dialogue: 0,0:16:16.22,0:16:18.22,Default,,0000,0000,0000,,When the player has 0 health remaining Dialogue: 0,0:16:18.22,0:16:20.22,Default,,0000,0000,0000,,we allow him to fall through the level by Dialogue: 0,0:16:20.22,0:16:22.63,Default,,0000,0000,0000,,setting his colliders to triggers, Dialogue: 0,0:16:22.63,0:16:24.63,Default,,0000,0000,0000,,and we move him to the very front of rendering Dialogue: 0,0:16:24.63,0:16:28.19,Default,,0000,0000,0000,,by placing his sprite renderers on the UI Sorting layer, Dialogue: 0,0:16:28.19,0:16:31.59,Default,,0000,0000,0000,,one we've made to render in front of everything in the game. Dialogue: 0,0:16:31.59,0:16:34.22,Default,,0000,0000,0000,,We have 2 animations for when the player dies. Dialogue: 0,0:16:34.22,0:16:37.25,Default,,0000,0000,0000,,1 called Death, where he loses his hat and gun Dialogue: 0,0:16:37.25,0:16:38.63,Default,,0000,0000,0000,,and another called Falling. Dialogue: 0,0:16:38.63,0:16:40.63,Default,,0000,0000,0000,,We naturally transition in to Falling once Dialogue: 0,0:16:40.63,0:16:44.00,Default,,0000,0000,0000,,the Death animation completes by using the Exit Time Dialogue: 0,0:16:44.00,0:16:47.24,Default,,0000,0000,0000,,as our transition condition in the animator. Dialogue: 0,0:16:50.78,0:16:52.78,Default,,0000,0000,0000,,Finally, to stop the player moving the character Dialogue: 0,0:16:52.78,0:16:55.28,Default,,0000,0000,0000,,or shooting during the Death sequence Dialogue: 0,0:16:55.28,0:16:58.34,Default,,0000,0000,0000,,we disable the PlayerControl and Gun scripts. Dialogue: 0,0:16:58.34,0:17:00.73,Default,,0000,0000,0000,,Because the Die function is made as public Dialogue: 0,0:17:00.73,0:17:03.33,Default,,0000,0000,0000,,we can call it from elsewhere, such as if the player Dialogue: 0,0:17:03.33,0:17:05.04,Default,,0000,0000,0000,,falls in to the water. Dialogue: 0,0:17:05.04,0:17:07.73,Default,,0000,0000,0000,,To reset the game once the player does hit the water Dialogue: 0,0:17:07.73,0:17:09.73,Default,,0000,0000,0000,,we have a KillTrigger object, which simply Dialogue: 0,0:17:09.73,0:17:12.46,Default,,0000,0000,0000,,comprises of a trigger collider and a script. Dialogue: 0,0:17:12.46,0:17:15.01,Default,,0000,0000,0000,,For most of the game the purpose of the Remover script Dialogue: 0,0:17:15.01,0:17:17.01,Default,,0000,0000,0000,,is to remove our enemy objects that fall in Dialogue: 0,0:17:17.01,0:17:19.79,Default,,0000,0000,0000,,to the river, and instantiate a splash animation Dialogue: 0,0:17:19.79,0:17:21.44,Default,,0000,0000,0000,,and sound effect. Dialogue: 0,0:17:21.44,0:17:24.00,Default,,0000,0000,0000,,However, when the player is detected by this trigger Dialogue: 0,0:17:24.00,0:17:27.09,Default,,0000,0000,0000,,we call the Die function in the PlayerHealth script Dialogue: 0,0:17:27.09,0:17:29.09,Default,,0000,0000,0000,,and also disable CameraTracking Dialogue: 0,0:17:29.09,0:17:31.09,Default,,0000,0000,0000,,whilst moving the player off screen Dialogue: 0,0:17:31.09,0:17:34.53,Default,,0000,0000,0000,,and calling a co-routiene that pauses for 2 seconds Dialogue: 0,0:17:34.53,0:17:36.53,Default,,0000,0000,0000,,and then reloads the level. Dialogue: 0,0:17:37.08,0:17:39.08,Default,,0000,0000,0000,,But let's not dwell on the death of the player, Dialogue: 0,0:17:39.08,0:17:41.08,Default,,0000,0000,0000,,let's look at his survival and the tools that we give Dialogue: 0,0:17:41.08,0:17:42.48,Default,,0000,0000,0000,,him to do that. Dialogue: 0,0:17:42.48,0:17:44.48,Default,,0000,0000,0000,,Our game features 2 airdropped crates that Dialogue: 0,0:17:44.48,0:17:47.12,Default,,0000,0000,0000,,assist the player, 1 containing a bomb, Dialogue: 0,0:17:47.12,0:17:49.91,Default,,0000,0000,0000,,the other a med kit to boost health. Dialogue: 0,0:17:50.41,0:17:52.96,Default,,0000,0000,0000,,These crate drops are made up of 2 parts. Dialogue: 0,0:17:52.96,0:17:55.70,Default,,0000,0000,0000,,The crate itself and a parachute. Dialogue: 0,0:17:58.05,0:18:01.31,Default,,0000,0000,0000,,These 2 elements are nested beneath an empty parent object Dialogue: 0,0:18:01.31,0:18:03.77,Default,,0000,0000,0000,,to allow us to animate them as a group. Dialogue: 0,0:18:03.77,0:18:05.77,Default,,0000,0000,0000,,We position the 2 sprites so that the parachute's Dialogue: 0,0:18:05.77,0:18:08.48,Default,,0000,0000,0000,,centre is at the centre of the parent. Dialogue: 0,0:18:09.04,0:18:11.91,Default,,0000,0000,0000,,This way the animation can swing left and right Dialogue: 0,0:18:11.91,0:18:15.31,Default,,0000,0000,0000,,as if the entire parachuting crate is floating to the ground. Dialogue: 0,0:18:15.31,0:18:17.31,Default,,0000,0000,0000,,We then simply add a rigidbody to cause Dialogue: 0,0:18:17.31,0:18:19.31,Default,,0000,0000,0000,,gravity to pull the object down Dialogue: 0,0:18:19.31,0:18:21.31,Default,,0000,0000,0000,,and add colliders to the crate so that Dialogue: 0,0:18:21.31,0:18:23.31,Default,,0000,0000,0000,,we can detect when it lands and when Dialogue: 0,0:18:23.31,0:18:24.96,Default,,0000,0000,0000,,the player picks up the crate. Dialogue: 0,0:18:24.96,0:18:26.96,Default,,0000,0000,0000,,Upon landing we transition to a second Dialogue: 0,0:18:26.96,0:18:30.51,Default,,0000,0000,0000,,animation state which scales the parachute down. Dialogue: 0,0:18:30.51,0:18:33.31,Default,,0000,0000,0000,,Like other parts of our game, the animator handles Dialogue: 0,0:18:33.31,0:18:34.92,Default,,0000,0000,0000,,the states of the object. Dialogue: 0,0:18:34.92,0:18:36.92,Default,,0000,0000,0000,,We can see that by default it plays the Dialogue: 0,0:18:36.92,0:18:38.92,Default,,0000,0000,0000,,floatDown animation state Dialogue: 0,0:18:38.92,0:18:40.92,Default,,0000,0000,0000,,but then switches to a landing state Dialogue: 0,0:18:40.92,0:18:43.47,Default,,0000,0000,0000,,when the trigger Land is set to true. Dialogue: 0,0:18:43.97,0:18:47.38,Default,,0000,0000,0000,,In our script we do this using an onTriggerEnter function, Dialogue: 0,0:18:47.38,0:18:49.73,Default,,0000,0000,0000,,which detects the ground via a tag. Dialogue: 0,0:18:49.73,0:18:52.82,Default,,0000,0000,0000,,We also detatch the crate itself from the parent object Dialogue: 0,0:18:52.82,0:18:55.10,Default,,0000,0000,0000,,and give it a rigidbody of it's own Dialogue: 0,0:18:55.10,0:18:57.49,Default,,0000,0000,0000,,so that it can interact with the environment Dialogue: 0,0:18:57.49,0:19:00.62,Default,,0000,0000,0000,,resting realistically on a slope if it lands on one. Dialogue: 0,0:19:00.62,0:19:03.67,Default,,0000,0000,0000,,Let's focus on the bomb first of all. Dialogue: 0,0:19:03.67,0:19:05.67,Default,,0000,0000,0000,,Picking up the bomb crate is handled on the Dialogue: 0,0:19:05.67,0:19:08.48,Default,,0000,0000,0000,,BombPickup script, attached to the crate. Dialogue: 0,0:19:08.48,0:19:11.06,Default,,0000,0000,0000,,We pickup the crate by destroying it and adding to Dialogue: 0,0:19:11.06,0:19:13.06,Default,,0000,0000,0000,,the count of bombs that the player has Dialogue: 0,0:19:13.06,0:19:15.06,Default,,0000,0000,0000,,in the script attached to the player called Dialogue: 0,0:19:15.06,0:19:16.74,Default,,0000,0000,0000,,LayBombs Dialogue: 0,0:19:17.56,0:19:19.56,Default,,0000,0000,0000,,The LayBombs script simply checks if Dialogue: 0,0:19:19.56,0:19:21.56,Default,,0000,0000,0000,,the player is carrying a bomb Dialogue: 0,0:19:21.56,0:19:23.56,Default,,0000,0000,0000,,and then instantiates an instance Dialogue: 0,0:19:23.56,0:19:25.56,Default,,0000,0000,0000,,of the Bomb prefab. Dialogue: 0,0:19:27.42,0:19:29.95,Default,,0000,0000,0000,,The Bomb prefab has a timed fuse Dialogue: 0,0:19:29.95,0:19:32.15,Default,,0000,0000,0000,,which waits by using an yield within the Dialogue: 0,0:19:32.15,0:19:34.15,Default,,0000,0000,0000,,BombDetonation co-routiene Dialogue: 0,0:19:34.15,0:19:36.15,Default,,0000,0000,0000,,before calling the Explode function. Dialogue: 0,0:19:36.80,0:19:39.54,Default,,0000,0000,0000,,The Explode function performs several actions. Dialogue: 0,0:19:39.54,0:19:41.54,Default,,0000,0000,0000,,First it resets the bombLaid variable Dialogue: 0,0:19:41.54,0:19:43.80,Default,,0000,0000,0000,,to allow another bomb to be deployed, Dialogue: 0,0:19:43.80,0:19:45.80,Default,,0000,0000,0000,,it tells the pickup spawner it is allowed to Dialogue: 0,0:19:45.80,0:19:47.80,Default,,0000,0000,0000,,spawn a new crate drop and kills Dialogue: 0,0:19:47.80,0:19:49.80,Default,,0000,0000,0000,,enemies within a defined blast radian. Dialogue: 0,0:19:50.52,0:19:53.06,Default,,0000,0000,0000,,Let's take a look at how this last part works. Dialogue: 0,0:19:53.06,0:19:55.06,Default,,0000,0000,0000,,Because bombs are lethal to enemies regardless of Dialogue: 0,0:19:55.06,0:19:57.18,Default,,0000,0000,0000,,their remaining hit points we use the Dialogue: 0,0:19:57.18,0:19:59.98,Default,,0000,0000,0000,,Physics.OverlapCircleAll to collect all objects Dialogue: 0,0:19:59.98,0:20:03.47,Default,,0000,0000,0000,,tagged Enemy within a certain radius of the bomb. Dialogue: 0,0:20:03.47,0:20:06.61,Default,,0000,0000,0000,,We then run a foreach loop for every enemy found Dialogue: 0,0:20:06.61,0:20:10.66,Default,,0000,0000,0000,,setting their health to 0 finding a vector from where the bomb was Dialogue: 0,0:20:10.66,0:20:12.66,Default,,0000,0000,0000,,to where the enemy is, in order to apply Dialogue: 0,0:20:12.66,0:20:15.54,Default,,0000,0000,0000,,a force in the direction of that vector. Dialogue: 0,0:20:16.30,0:20:18.54,Default,,0000,0000,0000,,Once the foreach loop is complete Dialogue: 0,0:20:18.54,0:20:21.38,Default,,0000,0000,0000,,we play and instantiate visual effects, Dialogue: 0,0:20:21.38,0:20:23.38,Default,,0000,0000,0000,,play an audio clip for the explosion Dialogue: 0,0:20:23.38,0:20:25.91,Default,,0000,0000,0000,,and of course destroy the bomb itself. Dialogue: 0,0:20:26.88,0:20:29.25,Default,,0000,0000,0000,,The visual of the explosion is twofold. Dialogue: 0,0:20:29.25,0:20:31.25,Default,,0000,0000,0000,,The main part is a simple circle that appears Dialogue: 0,0:20:31.25,0:20:33.58,Default,,0000,0000,0000,,briefly and is then destroyed Dialogue: 0,0:20:33.58,0:20:35.58,Default,,0000,0000,0000,,and the second part is a particle system of Dialogue: 0,0:20:35.58,0:20:37.58,Default,,0000,0000,0000,,stars that reuses the same sprites Dialogue: 0,0:20:37.58,0:20:39.58,Default,,0000,0000,0000,,as our rocket explosion. Dialogue: 0,0:20:42.26,0:20:44.26,Default,,0000,0000,0000,,For efficiency we keep this particle Dialogue: 0,0:20:44.26,0:20:46.26,Default,,0000,0000,0000,,system in the scene at all times Dialogue: 0,0:20:46.26,0:20:48.26,Default,,0000,0000,0000,,and when it is required we use code Dialogue: 0,0:20:48.26,0:20:51.74,Default,,0000,0000,0000,,to move the system to the desired position and play it. Dialogue: 0,0:20:52.51,0:20:54.51,Default,,0000,0000,0000,,This keeps the particle system in memory Dialogue: 0,0:20:54.51,0:20:56.51,Default,,0000,0000,0000,,and makes the game more efficient. Dialogue: 0,0:20:57.01,0:20:59.01,Default,,0000,0000,0000,,It's worth noting that we can do this Dialogue: 0,0:20:59.01,0:21:01.01,Default,,0000,0000,0000,,because we know we will only have 1 Dialogue: 0,0:21:01.01,0:21:04.67,Default,,0000,0000,0000,,single explosion in the scene at any one time Dialogue: 0,0:21:04.67,0:21:07.79,Default,,0000,0000,0000,,as the player can only throw 1 bomb at a time. Dialogue: 0,0:21:07.79,0:21:09.79,Default,,0000,0000,0000,,This is why keeping our particle system in the Dialogue: 0,0:21:09.79,0:21:11.79,Default,,0000,0000,0000,,scene and replaying it is more Dialogue: 0,0:21:11.79,0:21:14.94,Default,,0000,0000,0000,,efficient than creating instances and then removing them. Dialogue: 0,0:21:15.71,0:21:17.62,Default,,0000,0000,0000,,With the rocket explosion however, Dialogue: 0,0:21:17.62,0:21:19.62,Default,,0000,0000,0000,,we can have many at once so we do Dialogue: 0,0:21:19.62,0:21:21.62,Default,,0000,0000,0000,,need to spawn and remove them. Dialogue: 0,0:21:22.12,0:21:24.12,Default,,0000,0000,0000,,Now let's take a look at what happens when our player Dialogue: 0,0:21:24.12,0:21:26.12,Default,,0000,0000,0000,,kills an enemy and scores points. Dialogue: 0,0:21:26.62,0:21:28.44,Default,,0000,0000,0000,,This is done in 2 parts, Dialogue: 0,0:21:28.44,0:21:31.67,Default,,0000,0000,0000,,a scoring animation that plays showing 100 points earned Dialogue: 0,0:21:31.67,0:21:33.67,Default,,0000,0000,0000,,and the score UI at the top of the screen Dialogue: 0,0:21:33.67,0:21:35.53,Default,,0000,0000,0000,,that increments. Dialogue: 0,0:21:35.53,0:21:38.30,Default,,0000,0000,0000,,The score animation is made up to 2 number sprites, Dialogue: 0,0:21:38.30,0:21:40.19,Default,,0000,0000,0000,,a 1 and a 0. Dialogue: 0,0:21:40.19,0:21:42.87,Default,,0000,0000,0000,,We place this in the scene under an empty parent object Dialogue: 0,0:21:42.87,0:21:46.04,Default,,0000,0000,0000,,and animated them using a simple destroyer script to Dialogue: 0,0:21:46.04,0:21:49.19,Default,,0000,0000,0000,,remove them from the scene when the animation is complete. Dialogue: 0,0:21:49.19,0:21:51.19,Default,,0000,0000,0000,,We call the destroyer function in the script Dialogue: 0,0:21:51.19,0:21:53.19,Default,,0000,0000,0000,,by placing an animation event Dialogue: 0,0:21:53.19,0:21:55.19,Default,,0000,0000,0000,,at the end of the timeline. Dialogue: 0,0:22:06.14,0:22:09.70,Default,,0000,0000,0000,,The ScoreUI itself is a simple GUI text component Dialogue: 0,0:22:09.70,0:22:11.70,Default,,0000,0000,0000,,with a custom font and script that manages Dialogue: 0,0:22:11.70,0:22:13.70,Default,,0000,0000,0000,,the score for the player. Dialogue: 0,0:22:13.70,0:22:16.76,Default,,0000,0000,0000,,The Score variable is public, meaning that we can address it Dialogue: 0,0:22:16.76,0:22:18.98,Default,,0000,0000,0000,,from the Enemy script when they are killed Dialogue: 0,0:22:18.98,0:22:20.98,Default,,0000,0000,0000,,and add 100 points to the value. Dialogue: 0,0:22:20.98,0:22:22.98,Default,,0000,0000,0000,,Speaking of the enemies, let's take a look Dialogue: 0,0:22:22.98,0:22:24.98,Default,,0000,0000,0000,,at them more in depth now. Dialogue: 0,0:22:25.48,0:22:28.26,Default,,0000,0000,0000,,In our game we have 2 types of alien enemy, Dialogue: 0,0:22:28.26,0:22:30.85,Default,,0000,0000,0000,,a green slug-like monster and a smarter Dialogue: 0,0:22:30.85,0:22:32.85,Default,,0000,0000,0000,,alien that brought his ship with him for Dialogue: 0,0:22:32.85,0:22:34.56,Default,,0000,0000,0000,,protection during the invasion. Dialogue: 0,0:22:34.56,0:22:36.56,Default,,0000,0000,0000,,These characters share the same script Dialogue: 0,0:22:36.56,0:22:38.56,Default,,0000,0000,0000,,as the behaviour is very similar Dialogue: 0,0:22:38.56,0:22:40.88,Default,,0000,0000,0000,,and we allow for differing movement speeds Dialogue: 0,0:22:40.88,0:22:42.88,Default,,0000,0000,0000,,and amounts of hit points by setting Dialogue: 0,0:22:42.88,0:22:45.76,Default,,0000,0000,0000,,these as public variables in the Inspector. Dialogue: 0,0:22:46.64,0:22:49.09,Default,,0000,0000,0000,,Each enemy has it's own Walk animation. Dialogue: 0,0:22:49.09,0:22:51.09,Default,,0000,0000,0000,,The slug has a moving tail, whist the Dialogue: 0,0:22:51.09,0:22:54.44,Default,,0000,0000,0000,,ship-based enemy rocks back and forth as it approaches. Dialogue: 0,0:22:55.99,0:22:57.99,Default,,0000,0000,0000,,For the slug we used the sprite importer Dialogue: 0,0:22:57.99,0:22:59.99,Default,,0000,0000,0000,,to define the tail section of the graphic Dialogue: 0,0:22:59.99,0:23:01.99,Default,,0000,0000,0000,,as a separate sprite element, Dialogue: 0,0:23:01.99,0:23:04.44,Default,,0000,0000,0000,,meaning that we could animate it individually Dialogue: 0,0:23:04.44,0:23:07.48,Default,,0000,0000,0000,,and avoid having to scale the entire sprite. Dialogue: 0,0:23:07.48,0:23:09.48,Default,,0000,0000,0000,,By setting the pivot to the right Dialogue: 0,0:23:09.48,0:23:12.12,Default,,0000,0000,0000,,we are able to animate the tail expanding and contracting Dialogue: 0,0:23:12.12,0:23:14.12,Default,,0000,0000,0000,,from that point. Dialogue: 0,0:23:16.48,0:23:19.92,Default,,0000,0000,0000,,For added character we then move the eyelid up and down Dialogue: 0,0:23:19.92,0:23:21.92,Default,,0000,0000,0000,,and we use the Z value to sort the sprites Dialogue: 0,0:23:21.92,0:23:24.86,Default,,0000,0000,0000,,amongst one another, the eye being below the eyelid Dialogue: 0,0:23:24.86,0:23:26.86,Default,,0000,0000,0000,,so that we could animate it over the top. Dialogue: 0,0:23:28.86,0:23:31.27,Default,,0000,0000,0000,,The second enemy's animation was much simpler Dialogue: 0,0:23:31.27,0:23:34.05,Default,,0000,0000,0000,,and just meant that we rotated it back and forth. Dialogue: 0,0:23:35.80,0:23:37.80,Default,,0000,0000,0000,,For the mechanics of moving the enemies Dialogue: 0,0:23:37.80,0:23:41.23,Default,,0000,0000,0000,,we drive them by setting the velocity of the rigidbody. Dialogue: 0,0:23:41.23,0:23:43.89,Default,,0000,0000,0000,,When they encounter an obstacle such as a wall Dialogue: 0,0:23:43.89,0:23:47.83,Default,,0000,0000,0000,,they detect this by using a Physics.OverlapPoint function, Dialogue: 0,0:23:47.83,0:23:51.32,Default,,0000,0000,0000,,which checks for a point in space overlapping a collider. Dialogue: 0,0:23:51.32,0:23:53.85,Default,,0000,0000,0000,,Our walls, the towers at each side of the level, Dialogue: 0,0:23:53.85,0:23:55.85,Default,,0000,0000,0000,,are tagged as obstacles. Dialogue: 0,0:23:55.85,0:23:59.16,Default,,0000,0000,0000,,When this function detects them it calls the Flip function, Dialogue: 0,0:23:59.16,0:24:01.77,Default,,0000,0000,0000,,it reverses the X scale of the enemy Dialogue: 0,0:24:01.77,0:24:04.07,Default,,0000,0000,0000,,sending them moving in a different direction. Dialogue: 0,0:24:04.07,0:24:06.07,Default,,0000,0000,0000,,To kill the enemies, each time a rocket collides Dialogue: 0,0:24:06.07,0:24:09.04,Default,,0000,0000,0000,,with them it's script calls the Hurt function on Dialogue: 0,0:24:09.04,0:24:11.04,Default,,0000,0000,0000,,the particular enemy that it's hit. Dialogue: 0,0:24:14.96,0:24:16.96,Default,,0000,0000,0000,,In this function we subtract 1 from the Dialogue: 0,0:24:16.96,0:24:19.21,Default,,0000,0000,0000,,hit points of the particular enemy. Dialogue: 0,0:24:19.21,0:24:21.21,Default,,0000,0000,0000,,We then keep tabs on the enemy's health Dialogue: 0,0:24:21.21,0:24:23.21,Default,,0000,0000,0000,,inside the fixed update function. Dialogue: 0,0:24:23.21,0:24:27.12,Default,,0000,0000,0000,,If it drops to 0 we call the Death function. Dialogue: 0,0:24:31.23,0:24:33.92,Default,,0000,0000,0000,,When they die we perform a number of functions. Dialogue: 0,0:24:33.92,0:24:35.92,Default,,0000,0000,0000,,Firstly we disable all sprite renderers Dialogue: 0,0:24:35.92,0:24:37.92,Default,,0000,0000,0000,,as our 2D characters are made up of a Dialogue: 0,0:24:37.92,0:24:39.92,Default,,0000,0000,0000,,number of sprite objects that are animated. Dialogue: 0,0:24:40.94,0:24:42.94,Default,,0000,0000,0000,,This is because we simply want to swap out the Dialogue: 0,0:24:42.94,0:24:44.94,Default,,0000,0000,0000,,animated elements for a single sprite Dialogue: 0,0:24:44.94,0:24:46.94,Default,,0000,0000,0000,,of the dead character Dialogue: 0,0:24:47.74,0:24:49.74,Default,,0000,0000,0000,,We do this with the main sprite renderer by Dialogue: 0,0:24:49.74,0:24:51.74,Default,,0000,0000,0000,,setting it to use the sprite assigned to Dialogue: 0,0:24:51.74,0:24:54.16,Default,,0000,0000,0000,,the deadEnemy variable. Dialogue: 0,0:24:54.16,0:24:56.16,Default,,0000,0000,0000,,We then add to the score using the public Dialogue: 0,0:24:56.16,0:24:58.16,Default,,0000,0000,0000,,variable in the Score script Dialogue: 0,0:24:58.16,0:25:00.74,Default,,0000,0000,0000,,and we add some visual flare to the enemy's death Dialogue: 0,0:25:00.74,0:25:03.53,Default,,0000,0000,0000,,by adding torque to spin them as they die. Dialogue: 0,0:25:04.45,0:25:06.45,Default,,0000,0000,0000,,Because we need the enemies to fall through the Dialogue: 0,0:25:06.45,0:25:08.88,Default,,0000,0000,0000,,environment and land in the river when they die Dialogue: 0,0:25:08.88,0:25:10.88,Default,,0000,0000,0000,,we find all colliders on the object Dialogue: 0,0:25:10.88,0:25:13.59,Default,,0000,0000,0000,,and set their IsTrigger parameter to true. Dialogue: 0,0:25:13.59,0:25:15.14,Default,,0000,0000,0000,,This means that they will pass through the Dialogue: 0,0:25:15.14,0:25:17.42,Default,,0000,0000,0000,,environment colliders. Dialogue: 0,0:25:17.42,0:25:20.05,Default,,0000,0000,0000,,We then choose from an array of death audio clips Dialogue: 0,0:25:20.05,0:25:22.05,Default,,0000,0000,0000,,and play one of them back, before creating Dialogue: 0,0:25:22.05,0:25:25.47,Default,,0000,0000,0000,,an instance of the Score animation we showed you earlier. Dialogue: 0,0:25:27.88,0:25:29.88,Default,,0000,0000,0000,,To remove the dead enemy from the scene Dialogue: 0,0:25:29.88,0:25:31.88,Default,,0000,0000,0000,,we rely on the killTrigger object Dialogue: 0,0:25:31.88,0:25:34.76,Default,,0000,0000,0000,,It performs the same function as discussed earlier Dialogue: 0,0:25:34.76,0:25:36.76,Default,,0000,0000,0000,,as any non-player object touching it Dialogue: 0,0:25:36.76,0:25:39.95,Default,,0000,0000,0000,,will cause a splash animation and remove that object. Dialogue: 0,0:25:39.95,0:25:41.95,Default,,0000,0000,0000,,The sound effect of them hitting the water is Dialogue: 0,0:25:41.95,0:25:43.95,Default,,0000,0000,0000,,an audio clip attached to the animated Dialogue: 0,0:25:43.95,0:25:45.95,Default,,0000,0000,0000,,splash which plays on awake Dialogue: 0,0:25:45.95,0:25:47.95,Default,,0000,0000,0000,,so that when we create an instance of the animated Dialogue: 0,0:25:47.95,0:25:50.63,Default,,0000,0000,0000,,object we hear the sound right away. Dialogue: 0,0:25:55.15,0:25:57.15,Default,,0000,0000,0000,,To finish the game level re decorated the Dialogue: 0,0:25:57.15,0:25:59.15,Default,,0000,0000,0000,,background with a number of moving props Dialogue: 0,0:25:59.15,0:26:02.30,Default,,0000,0000,0000,,in order to make our game environment feel more dynamic. Dialogue: 0,0:26:02.30,0:26:05.70,Default,,0000,0000,0000,,We added flying swans, plus buses and taxis that drive Dialogue: 0,0:26:05.70,0:26:07.12,Default,,0000,0000,0000,,along the river bank. Dialogue: 0,0:26:07.12,0:26:10.63,Default,,0000,0000,0000,,First was the swan, which was created from a sprite sheet, Dialogue: 0,0:26:10.63,0:26:12.63,Default,,0000,0000,0000,,drawn in Photoshop and imported using Dialogue: 0,0:26:12.63,0:26:14.63,Default,,0000,0000,0000,,the Multiple Sprite Mode import setting Dialogue: 0,0:26:14.63,0:26:16.05,Default,,0000,0000,0000,,in the Inspector. Dialogue: 0,0:26:16.05,0:26:18.80,Default,,0000,0000,0000,,By choosing this approach Unity automates choosing Dialogue: 0,0:26:18.80,0:26:20.80,Default,,0000,0000,0000,,each frame in the sheet and importing Dialogue: 0,0:26:20.80,0:26:22.80,Default,,0000,0000,0000,,it as a separate sprite under the parent Dialogue: 0,0:26:22.80,0:26:24.58,Default,,0000,0000,0000,,hierarchy of the asset. Dialogue: 0,0:26:24.58,0:26:27.28,Default,,0000,0000,0000,,Because this is a linear set of animation frames Dialogue: 0,0:26:27.28,0:26:29.28,Default,,0000,0000,0000,,we could simply drag all of these sprites in to the Dialogue: 0,0:26:29.28,0:26:32.35,Default,,0000,0000,0000,,scene to let Unity animate them for us. Dialogue: 0,0:26:32.35,0:26:35.32,Default,,0000,0000,0000,,Et voila, our animated swan is ready to add Dialogue: 0,0:26:35.32,0:26:37.76,Default,,0000,0000,0000,,as a background element. Dialogue: 0,0:26:37.76,0:26:40.16,Default,,0000,0000,0000,,The swan was then given a rigidbody2D Dialogue: 0,0:26:40.16,0:26:42.16,Default,,0000,0000,0000,,so that we can use velocity to send it Dialogue: 0,0:26:42.16,0:26:43.37,Default,,0000,0000,0000,,across the screen. Dialogue: 0,0:26:43.37,0:26:47.33,Default,,0000,0000,0000,,As with the bus and the cab, the swan is saved as a prefab. Dialogue: 0,0:26:49.26,0:26:51.26,Default,,0000,0000,0000,,For the bus and taxi prefabs we Dialogue: 0,0:26:51.26,0:26:53.26,Default,,0000,0000,0000,,simply separated the bodies and wheels of Dialogue: 0,0:26:53.26,0:26:55.26,Default,,0000,0000,0000,,the vehicles in the sprite importer Dialogue: 0,0:26:55.26,0:26:58.39,Default,,0000,0000,0000,,and made a simple bobbing animation. Dialogue: 0,0:26:58.39,0:27:00.79,Default,,0000,0000,0000,,Applying a 2d rigidbody to these as well, Dialogue: 0,0:27:00.79,0:27:02.79,Default,,0000,0000,0000,,we were able to drive them across the screen Dialogue: 0,0:27:02.79,0:27:04.38,Default,,0000,0000,0000,,using velocity. Dialogue: 0,0:27:07.28,0:27:10.27,Default,,0000,0000,0000,,For all 3 props, the bus, taxi and the swan Dialogue: 0,0:27:10.27,0:27:12.27,Default,,0000,0000,0000,,we created a script we could reuse Dialogue: 0,0:27:12.27,0:27:14.27,Default,,0000,0000,0000,,which is in charge of spawning them. Dialogue: 0,0:27:14.27,0:27:16.62,Default,,0000,0000,0000,,The BackgroundPropsSpawner script Dialogue: 0,0:27:16.62,0:27:19.84,Default,,0000,0000,0000,,also handles the frequency, a speed to give them Dialogue: 0,0:27:19.84,0:27:21.84,Default,,0000,0000,0000,,and where on screen to spawn them. Dialogue: 0,0:27:21.84,0:27:24.52,Default,,0000,0000,0000,,This meant that we could make 3 creator objects Dialogue: 0,0:27:24.52,0:27:26.52,Default,,0000,0000,0000,,with the same script on. Dialogue: 0,0:27:26.52,0:27:28.52,Default,,0000,0000,0000,,Changing which prefab will be spawned Dialogue: 0,0:27:28.52,0:27:30.52,Default,,0000,0000,0000,,and what properties to give it. Dialogue: 0,0:27:30.52,0:27:33.85,Default,,0000,0000,0000,,Take a look at the comments in the script to learn more. Dialogue: 0,0:27:33.85,0:27:36.17,Default,,0000,0000,0000,,Finally, for more background dynamism, Dialogue: 0,0:27:36.17,0:27:40.41,Default,,0000,0000,0000,,we added rolling clouds, panning river details and fog. Dialogue: 0,0:27:41.32,0:27:44.52,Default,,0000,0000,0000,,We did this by adding 2 instances of the background sprite Dialogue: 0,0:27:44.52,0:27:48.00,Default,,0000,0000,0000,,to a parent object and simply used animation to slowly Dialogue: 0,0:27:48.00,0:27:50.00,Default,,0000,0000,0000,,pan them across the screen. Dialogue: 0,0:27:50.00,0:27:52.65,Default,,0000,0000,0000,,Because this animation loops our animation will Dialogue: 0,0:27:52.65,0:27:54.65,Default,,0000,0000,0000,,continue indefinitely. Dialogue: 0,0:27:59.18,0:28:01.03,Default,,0000,0000,0000,,And that's how we made our game. Dialogue: 0,0:28:01.03,0:28:03.03,Default,,0000,0000,0000,,We hope this overview has given you some idea of Dialogue: 0,0:28:03.03,0:28:05.52,Default,,0000,0000,0000,,how we create 2D games in Unity, Dialogue: 0,0:28:05.52,0:28:07.52,Default,,0000,0000,0000,,and we'll be creating more simply projects and Dialogue: 0,0:28:07.52,0:28:08.97,Default,,0000,0000,0000,,tutorials in the future. Dialogue: 0,0:28:08.97,0:28:11.69,Default,,0000,0000,0000,,We look forward to your feedback on Unity4.3 Dialogue: 0,0:28:11.69,0:28:13.69,Default,,0000,0000,0000,,and we can't wait to see the great 2D titles Dialogue: 0,0:28:13.69,0:28:14.96,Default,,0000,0000,0000,,that you'll come up with. Dialogue: 0,0:28:14.96,0:28:16.49,Default,,0000,0000,0000,,Thanks for watching.