Search Unity

Creating a precise collider from a .PNG with alpha channel

Discussion in '2D' started by Aahdin, Nov 20, 2013.

  1. Aahdin

    Aahdin

    Joined:
    May 21, 2013
    Posts:
    2
    I'm looking at the documentation for the 2d polygon collider, and it's saying there's an option to automatically create colliders straight from a sprite based on the image's alpha scale, with a slider for precision that shows how many vertices will be made.

    http://docs.unity3d.com/Documentation/Components/class-PolygonCollider2D.html

    However, in the editor I'm not seeing any of that besides the material, trigger, and collider info parts, and the automatic collider it generates usually only has like 10-15 vertices.



    Basically, what I did is I mapped out one of my games' levels as a low res image where each non-transparent pixel is a tile that I want a collider around, thinking that I could just have unity make a polygon collider for me and all I would have to do is make the image and alpha channel. The image I'm talking about would never appear anywhere in the game, it was just sort of a map of where I want to put my level's "ground" colliders.

    Doing all the edge colliders by hand doesn't seem like a practical option, as I need precise 90 degree angles, and using a bunch of individual square colliders might work, but would be time consuming and I figured I should probably check here to see if there's an easier way.
     
  2. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Sorry to say we seem to have a old image in the documentation. We indeed did have those sliders to adjust the detail and cutoff, but we had to cut this feature in the last minute because of some technical issues. They may make a comeback in some form in the future.
     
  3. Aahdin

    Aahdin

    Joined:
    May 21, 2013
    Posts:
    2
    Ah, that's too bad. So would it be fair to say that using a bunch of box colliders is probably my best bet?
     
  4. Kurius

    Kurius

    Joined:
    Sep 29, 2013
    Posts:
    412