Search Unity

Question Need help with tilemap collider 2d

Discussion in '2D' started by Nika582, Mar 4, 2021.

  1. Nika582

    Nika582

    Joined:
    Feb 3, 2021
    Posts:
    7
    Hello, I need help with making my tilemap colliders be squares of the full tile resolution (32x32), with no custom generated colliders for each individual tile. In the screenshot, if I push my player against the wall and jump (for exm. holding right and jumping, trying to get on the platform as soon as player is high enough) the player will be stopped by the collider. My question is: how do I make these colliders ignore the graphics of each tile, but instead stick to the resolution of said tiles?
    upload_2021-3-4_22-25-34.png
     
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,465
    They cant really ignore the graphics but they also aren't really influenced by them either (unless they are perfectly square or circlular). What is wrong with using an EdgeCollider2D and making it very closely represent the object? You would only need to use 1 Edge Collider for that object you show
     
  3. Nika582

    Nika582

    Joined:
    Feb 3, 2021
    Posts:
    7
    Well. Because I need to use it for an entire tilemap? What I need is a 32x32 box collider around all tiles, no matter if the tile is 5 pixels wide circle or if its a full 32x32 square
    upload_2021-3-4_23-58-37.png
     
  4. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    You could specify the Collider Type of each of your Tiles to be Grid. This will use the Grid Cell as the shape of the Collider for your Tile.
    upload_2021-3-5_9-29-40.png
     
  5. Nika582

    Nika582

    Joined:
    Feb 3, 2021
    Posts:
    7
    Didnt work the exact same way, but thats because I am using a rule tile. All I had to do is change the collider to grid there. Thank you very much for the help :)
    upload_2021-3-5_13-40-14.png
     

    Attached Files: