Journal 94 — Unity 2D Mobile, Dungeon Escape GameObject (Prefab) Brush and Collider Setup

Objective: Add GameObject Brush for collectibles and collider

In this follow up article, I will go over adding prefab brushes for a collectible, along with the colliders. Please note I’m using Unity 2021, so Prefab Brush has changed to GameObject Brush.

To start, let’s first slice up the diamond sprites.

From there, let’s create a diamond prefab.

After creating the prefab, we can view the “GameObject Brush” in the Tile Palette, and expand the window at the bottom of the palette window to drag in the prefab game object. From there, we can select “Paint” and we can paint the diamond prefab. Note the other diamond prefabs were painted on the active layer which is Ground, so that’s where they are added as children. You could also make your own new tilemap, such as “Diamond_Tilemap”, and paint the diamonds on that active tilemap.

Tilemap Colliders

Let’s add colliders so the player can interact and walk along the ground surface. We can start with adding a Tilemap Collider 2D to the ground.

Note that there are collider boundaries also on the interior which are unnecessary. To fix this we can add a Composite Collider 2D, which automatically adds a RigidBody 2D. We need to change the RigidBody 2D Body Type to “Static”, and from there, select the Tilemap Collider checkbox that says “Used By Composite”.

Thank you for your time!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Nielsen

Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.