Search Unity

[Solved]Tile Opacity for TileMap Collider 2D

Discussion in '2D' started by piraente, Sep 29, 2020.

  1. piraente

    piraente

    Joined:
    Oct 19, 2019
    Posts:
    10
    How much opacity is needed for a Sprite/Tile to be considered a collision tile by the TileMap Collision 2D component, or is it based on the color strength, so darker colors can be more transparent?
    I tried to draw with 50% transparent light blue Sprites/Tiles to create a collision tilemap, but they don't work.
    They need at least 80% to get considered.
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Offhand, I believe the threshold is around 78% (200/255)? Instead of adjusting that, perhaps you can consider adding custom physics shapes (https://docs.unity3d.com/Manual/CustomPhysicsShape.html) for your Sprites. This makes generation of the colliders faster by not having to determine an outline based on the shape of the Sprite in the Texture with alpha testing.
     
  3. piraente

    piraente

    Joined:
    Oct 19, 2019
    Posts:
    10
    It works with the customPhysicsShape, thank you.