Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

TileMap Collider 2D generating colliders wrong

Discussion in '2D Experimental Preview' started by zoeysaurusrex, Oct 4, 2017.

Thread Status:
Not open for further replies.
  1. zoeysaurusrex

    zoeysaurusrex

    Joined:
    Sep 25, 2012
    Posts:
    2
    Hello,

    I'm using Unity 2017.3 beta to play with a 2d project for fun.I'm running into a strange issue that occurs when I attempt to add a TileMap Collider 2D component to a Tilemap.The generated colliders look like they are roughly 10-15x the size of each cell in the TileMap. I have a screenshot of the isolated layer to highlight the issue I'm experiencing.




    Other factors to consider in case they help.

    Asset Configuration
    Tiles are 16x16, sliced from an imported asset with the following settings (only showing what I've changed for brevity):

    Pixels Per Unit: 16
    Sprite Mode: Multiple
    Wrap Mode: Clamp
    Filter Mode: Point

    Within the sprite editor, I've changed the slice settings from Automatic to Manual with a Pixel Size setting of 16x16.

    TileMap Configuration

    I am using three TileMaps and setting them with a layer order of 0, 1, and 2.
    TileMap's are all set with a shader of Sprites/Diffuse to support point lighting.


    Repro Steps
    1. Create a new 2D project
    2. Import an asset to use for tiles. I've used 16x16 tiles. Import settings should be modified according to my above configuration.
    3. Use the sprite editor to slice the sprites according to my above configuration.
    4. Create a TileMap in the scene and create a new TileMap palette with the sliced tiles.
    5. Paint a basic map using the brush.
    6. Select the TileMap from the scene use the "Add Component" to add a TileMap Collider 2D.

    At this point I feel like I've missed something very basic, like a simple checkbox or a setting.
     
  2. zoeysaurusrex

    zoeysaurusrex

    Joined:
    Sep 25, 2012
    Posts:
    2
    Gah! After messing with settings for hours and hours, I found the issue in an anecdote in another thread. Once I went to my asset, then into the sprite editor, and updated the physics shape, the colliders started generated correctly. I hope this helps someone else.
     
    Gilded1, Flubbi, Fourthings and 4 others like this.
  3. luizrd

    luizrd

    Joined:
    Mar 4, 2017
    Posts:
    5
    I'm not getting. What exactly did you do?
     
    Flubbi likes this.
  4. Puggy

    Puggy

    Joined:
    Jun 10, 2015
    Posts:
    6
    He went into the Sprite Editor (select your raw image in the project panel, and click the Sprite Editor button in the Inspector), and at the top left, you can click Sprite Editor and change it to "Edit Physics Shape" which will let you modify the shape the physics system uses for the Sprite(s).
     
    Flubbi likes this.
  5. Jon-Gao

    Jon-Gao

    Joined:
    Dec 9, 2012
    Posts:
    17


    Yes! it work! thanks @wmccullough
    I thought this was a bug since I never encounter in 2017.2, I don't even notice Sprite Editor has Physics Shape beforehand lol
     
  6. SonuIsLearning

    SonuIsLearning

    Joined:
    Jun 5, 2018
    Posts:
    1
    Rosa-Gao! u a genius, i was getting frustrated, thank you
     
  7. Flubbi

    Flubbi

    Joined:
    Feb 6, 2020
    Posts:
    1

    Thank you so much. This helped me a lot :D
     
  8. Gilded1

    Gilded1

    Joined:
    Jan 24, 2023
    Posts:
    1
    Thanks!
     
  9. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,458
    Please use the Like button to show appreciation rather than necroing very old threads.

    Thanks.
     
    MousePods likes this.
Thread Status:
Not open for further replies.