Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Tilemaps best practices

Discussion in '2D' started by manoosh, Jan 25, 2021.

  1. manoosh

    manoosh

    Joined:
    Jan 20, 2021
    Posts:
    2
    Hello everyone, I'm pretty new to Unity and I just finished some courses and tutorial found in the official documentation and I'm now in the process to apply what I learned so far using different assets from the ones provided with the tutorial, to see if I understood all the material.

    I'm trying to build a simple top-down game with some free asset I found online.
    My tile palette is composed, among others, of tiles like these:
    green.png fence.png house.png

    In order to have something like this:

    toghether.png (sorry for the quality, I recreated it in gimp since I'm not on the computer where I have Unity now)

    I had to create three Tilemaps under the same Grid. The botton tilemap containing the grass (sort order -2), the middle one containing the fence (sort order -1) and the top one containing the house (sort order 0).
    My first question is: given the tileset I have, is this the most efficient way to obtain what I needed?

    After having solved this problem I wanted to add a collider to the fence and to the house, but since now they are on two different tilemaps I cannot use a composite collider to optimize the collider's layout. Is there another way to do this in a more efficient way?
    Instead of using tiles for "interactable objects", should I use "proper" game objects instead?

    Thank you
     
    Last edited: Jan 25, 2021
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, this would depend on how you want other Renderers to interact and sort against each other in your Scene (eg. do characters work in between or behind the fence and the house?), as well as how you want to set Tiles in your Tilemaps (eg. in different layers or in one Tilemap).

    Colliders can be composited under one CompositeCollider2D provided that the CompositeCollider2D is in same or in a parent GameObject of the other Collider components.

    This would depend on how interactable your objects would be. Tiles on a Tilemap rely on the various Tilemap components, and may not be as flexible as a separate GameObject, but could be good enough for simple use-cases.
     
    manoosh likes this.
  3. manoosh

    manoosh

    Joined:
    Jan 20, 2021
    Posts:
    2
    Thank you very much.