Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

How to create a 3d polygon collider?

Discussion in 'Physics' started by cwbeta, Apr 26, 2017.

  1. cwbeta

    cwbeta

    Joined:
    Jan 12, 2017
    Posts:
    32
    In Physics2D, we can find Polygon Collider 2D, which can simply be edited by adding a vertex and just move it. It's pretty simply for 2D games to create colliders in Edit mode, or even in a level editor.

    However, in Physics(3D), we can only find colliders like Box Collider or Sphere Collider, which are not designed to be edited with vertexes.

    So if i want to create a 2D platform game with Z-Axis available, just like Rayman which can jump between platforms with different z-axis, it seems to be pretty hard to create colliders for the platforms.

    I don't appreciate the solution of using Mesh Collider or making a Box-Collider-group. That's so ugly and hard to use.

    Actually something like Polygon Collider 2D with a depth of z-axis makes more sense for me, because it's simple for the level designers to create great colliders.

    Is it possible to create such a collider?
     
  2. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    830
    I don't think that Box2D supports 2d colliders with different z-values, but I think you can still create a smart solution for your problem.

    You could set layers for the different z-values (lets say 4 layers), and then set the physics collision to only collide with themselves. Then you would need to switch the player layer every time they change the layer they are playing on and everything should work out the way you want it to (if I got you right).

    If you want to create 3D Mesh Colliders, you could use something like Pro builder Basic to create mesh colliders in the editor.
     
  3. cwbeta

    cwbeta

    Joined:
    Jan 12, 2017
    Posts:
    32
    Thank you for your reply! Actually I want to create 3d colliders, not 2d colliders. Just like I create a Polygon 2D Collider, and stretch the extremely thin collider to a thick one, thus making it a 3d collider.

    Pro builder Basic is quite amazing and it seems can solve my problem. I will create a demo project give it a try. I can't believe it's FREE! Thank you for your recommendation!
     
  4. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    830
    The basic version is free, the pro version actually costs 100$, but I guess for your needs the basic version will be sufficient :)
     
  5. cwbeta

    cwbeta

    Joined:
    Jan 12, 2017
    Posts:
    32
    AHA! Yes! It's sufficient! Thank you!:)
     
  6. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    830
    Awesome, always happy to help :)
     
  7. angelonit

    angelonit

    Joined:
    Mar 5, 2013
    Posts:
    40
    I came upon this situation some days ago and ended up making a unity tool that makes a MeshCollider with depth from PolygonCollider2d.

    It's called "Polygon Collider 2D to Mesh Collider" and it's for sale on my Itch io page (if you DM me I can send you a free testing copy)