Search Unity

Capsule Collider?

Discussion in '2D' started by Krileon, Feb 8, 2015.

  1. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Why is it there is no 2D capsule collider? The only way it seams I can make one is with 2 circle and 1 square collider, but this significantly complicates bound computations, collision toggling, and basically anything regarding the collision. Is there plans for a 2D capsule collider? Is there an alternative that'll let me generate one without having to use 3 colliders? A square collider does not work for a character moving over a tiled system as the corners get stuck (this is an already documented problem) so it's just not an acceptable collider.
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I 've read about this problem several times recently as well.

    I've not messed to much with customizing colliders - Yet, but there is an option to use a mesh as a colider isn't there?
    If so - create a simple low poly capsule in any 3d app. Import into Unity - set as collider, parent to character, remove mesh renderer.

    Is this a viable option?
     
  3. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    You need to use a Polygon collider for 2D. So you'd need to make a 2D sprite of the collider shape you want, generate a polygon collider for it. Then copy the collider component over. This does work, but it causes issues with origin and size scaling of the collider. So it's just not very reliable from my tests. There really needs to be a capsule collider and I can't understand why there isn't one; 2D games need characters too, lol. At any rate I've went ahead with a circle collider and will just need to make do.
     
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Hey Krileon - I read about this a lot a couple days ago. The genre that was discussed in the research I checked was platformers so I don't know if any of the info applies to tile based game but you are correct - this is a VERY documented issue.

    The solution most utilized for the platformer games was raycasting.

    Here are a couple links I saved. I don't know if it can help in your instance, but thought I'd share just in case.

    http://forum.unity3d.com/threads/hi...itting-intersection-of-edge-colliders.297111/
    http://www.gamasutra.com/blogs/Yoan...hobbyist_coder_1_2D_platformer_controller.php
    http://overdevelop.blogspot.co.uk/2013/12/2d-platformer-collision-detection-in.html
    http://www.iforce2d.net/b2dtut/ghost-vertices
    Thanks to @OboShape for the info provided in the first thread.

    Please update if you find a acceptable solution to go with.
     
  5. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    A circle collider works fine for me since my character is relatively small and the circle isn't larger than my tile size, but for many other games this will be an issue. I really hope Unity decides to add a capsule collider in the future, but for now my issue is solved.