Search Unity

Convert edge to polygon collider?

Discussion in '2D' started by Kaemalux, Apr 2, 2015.

  1. Kaemalux

    Kaemalux

    Joined:
    Aug 1, 2013
    Posts:
    45
    Hello!
    Is it possible somehow to convert a complex collider in another type?
    I am using 2D toolkit, but it creates meshes and in 2D it results in edge colliders: the problem is that i cannot use them properly with some other features, so i am asking if it possible to convert the collider in another one, keeping same vertex.
    Thanks in advance, have a nice day! :)

    Kaem
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    Probably could make editor script for that,
    - Take edgecollider vertices
    - assign them to polygoncollider verts

    Or does it just work if you delete edgecollider, and add polygoncollider component ?
    (and you can multiselect many objects to do that for all)
     
  3. Kaemalux

    Kaemalux

    Joined:
    Aug 1, 2013
    Posts:
    45
    Thanks for the suggestion! I tried to simply add polygon collider, but it is a complex mesh (made by 2D toolkit), so it simply add a polygon fitting the shape, but totally different from all vertices i need.

    You suggested an editor script, as i am a newbie could you point me what should i do and where to start scripting. I read something on the manual, so i suppose i should use
    public function SetPath(index: int, points: Vector2[]): void;
    but actually i don't know how and where to set it properly. Could you gently give me a bit more help? ^^
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    Can you show image how it should look and how it came out with polygoncollider?
     
  5. Kaemalux

    Kaemalux

    Joined:
    Aug 1, 2013
    Posts:
    45
    Sure, thanks. :)

    Here it is

    Exact collider is an edge one, built on the complex mesh derived by 2D toolkit. If i try to add a Polygon Collider 2D to the chunk, it is a simple pentagon without any consideration of vertices...

    Did you understand? ^^
     
  6. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    bump

    just noticed that 2dToolKit does this, need solid colliders not these empty ones...
     
  7. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    Last edited: Nov 3, 2015
    juelzsantana123 likes this.