Lynda.com: Become a Unity 2D Developer (Day 9)

UNITY 2D LEVEL DESIGN (...continued part II)

The Map Editor
Build a Level
The Build a level tutorial was merely a review of prior sessions.  Ultimately, I had to setup the scene folder and file.  Afterwards, I merely selected the Tile Map option that was setup within the prior tutorials.  From there, I painted a few of the textures and added the astronaut (Player) prefab onto the stage.  Furthermore, I made the astronaut the target of the Main Camera.  By doing this, it enables the camera to follow the player as they move around the level.  However, it is important to note that the textures currently on the stage do not have any collision detection so the astronaut simply falls through everything.

 
Add Collisions
The lack of 2D Collision will need to be remedied.  In order to make the tile picker options to be more robust, I had to modify a C# script, specifically TileMapEditor.  The goal is to include a "solid" checkbox prior to painting the texture onto the stage.  Not only does this make things much easier, it will safe a lot of time.  Which makes me wonder why this was not already included within the Unity build initially.  Nevertheless, this does open a lot of possibilities in the future for improving the development experience.
The first thing I did was create the GUI checkbox area for Solid.  In order to do this, I created a boolean variable and used the "EditorGUILayout" method, see below.

However, there are no values associated with the new Solid checkbox.  Although there is a menu option for Solid, it does not do anything at this time.   To correct this, I had to modify the C# script to include the BoxCollider2D method onto each painted tile, specifically when the checkbox is enabled or "ticked".

Add Layer Order
In order to dictate the layer order, I had to create a GUI menu option within the Inspector palette.  Much like the Solid checkbox, I had to create the instance using an int variable, specifically sortingOrder.  I was then able to add the GUILayout option for "Order In Layer".

Design a Simple Level
This exercise focused on getting the user familiar with the tile picker, from a designer perspective.  Below is the first custom level I have designed.  It is simple, but it has all of the components to lead the player from point A to B.  To be more specific, the astronaut starts at the top left corner.  From there, the player must navigate upwards to exit the level.
Populate the Level
This exercise was quite fun and satisfying.  I was able to take the exercise example and modify the level to include spikes and aliens.  This was another great example of leading the player from Point A to B.  However, this time around, I added obstacles into the mix.  It is important to note that when adding GameObjects onto the stage, pay close attention to the layer order.  Accidentally, I tested the level only to find my astronaut exploding randomly because the obstacles, alien(s), and spikes were not on the same layer order as the astronaut. 

Comments

Popular posts from this blog

JavaScript 30: JavaScript Drum Kit

Lynda.com: Become a Unity 2D Developer (Day 11..Sort of)

Back On the Coding Horse