Challenge #2 - Laying out the Tilemap

Tasks

  • Create a 2D level using Unity Tilemap system as shown in Fig 1(Hint: Refer to Tilemap Tutorial by Brackeys in Here)

  • Create a Rectangular Tilemap game object in the hierarchy window (Right click & select 2D object->Tilemap->Rectangular) and name it as Tilemap

  • Change the Camera size to 10, so we get a larger space to be covered by the camera

  • Use the Tileset in the folder path shown in Fig 2 to create the 2D level

  • Create a new Tilepalette in Assets->Tiles->Main and name it as "Tiles"

  • Move the Tileset Asset into the Tilepalette

  • Draw the 2D level using the the new Tileset assets in the Tilepalette

  • Add a TilemapCollider2D component to the Tilemap game object

  • Add a CompositeCollider2D to the Tilemap game object. Note: for composite collider to take effect you must check the "use by composite" option in the TilemapCollider2D component. Also observe adding a Composite Collider has automatically added a RigidBody2D component to the Tilemap game object.

  • Change the body type to "Kinematic" in the Rigidbody2D component

  • To avoid the loading period when you click play make the following configuration setting in edit menu->Project Settings -> Editor as shown in Fig 3

Note - Tilemap collider will create a Collider for every grid in the Tilemap and is computation intensive. To avoid computation load while playing a game its better to add a composite collider which adds a collider approximating to the outline of the object it covers there by reducing the load on the engine to compute collisions during every frame.

2d level.jpg
Tileset path.jpg
playmode setting.jpg

Fig 1

Fig 2

Fig 3