Search Unity

Cylinder Colliders

Discussion in 'Physics' started by ScottySR, Aug 16, 2021.

  1. ScottySR

    ScottySR

    Joined:
    Sep 29, 2018
    Posts:
    49
    Why haven't these been added yet? Afaik these have been requested since 2009. For 3D applications cylinder shaped colliders are best for humanoid shaped characters. Box colliders are ok, but there are few downsides. First one is that if the collider rotates with player, the corner of the box can clip a damage source or slide off a platform when turning. The second is that if the corners of two box colliders hit it makes it feel like you take hit farther away (Minecraft suffers from this problem (especially with spiders) when facing diagonally relative to the block grid because hitboxes don't rotate). Cylinder shapes shouldn't be too hard to calculate, so why haven't they been added yet?
     
  2. Geckoo

    Geckoo

    Joined:
    Dec 7, 2014
    Posts:
    144
    Hello. What about the capsule collider which seems to be the best way to simulate a body? This way you can efficiently simulate a slip when the player is on the edge of a mesh like some stairs, a roof, a platform, etc. With a cylinder collider, you cannot do that - instead you could stay on the edge and it's not really realistic. Respectfully, I think that a cylinder collider is just useless - and a box collider is probably the worst thing that you can do - except if you are creating a game with cubes as enemies and player :) ++
     
    Last edited: Aug 17, 2021
  3. entirelydoomed

    entirelydoomed

    Joined:
    Mar 26, 2021
    Posts:
    67
    I think cylinder colliders are just much harder to process than say capsule collider and other primitives so there's no reason to add them among primitives. At the end of the day you can just use cylinder mesh and add a convex mesh collider component to it. I believe there is a simple cylinder mesh in unity so you don't have to import it from a 3D software.
     
    Edy likes this.
  4. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,928
    Never seen a 3D app that uses cylinders for character collision. The usual shape used is a capsule, which is both cheaper and yields smoother results.
     
  5. ScottySR

    ScottySR

    Joined:
    Sep 29, 2018
    Posts:
    49
    What if you don't want your character to slip off?
     
  6. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,928
    Either use a convex mesh collider, or a capsule w/ high friction. This is however not what most games do.

    The typical approach is using a capsule as it allows the character to run over small edges, stairs, and similar obstacles. A cylinder or any other flat-base shape would cause the character to bump against the smallest protrusion in the floor.
     
  7. entirelydoomed

    entirelydoomed

    Joined:
    Mar 26, 2021
    Posts:
    67
    Constrain rotation on all 3 axis if you are using rigidbody. This is really essential and it will remove the sliding almost completely. Also if you don't constraint collision, physic material on your collider won't have any effect at all.
     
  8. LarryTheBrave

    LarryTheBrave

    Joined:
    Nov 20, 2016
    Posts:
    24
    Use blender, make a simple cylinder, export as .obj, to Unity, and parent your cylinder GameObject to that. Use the parent for PHYSICS ONLY with a Mesh Collider and delete any rendering. The GameObject child will be VISUAL only with rendering. Make sure they are matching size!
     
    Hozgen90 and mackeraldev like this.
  9. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    I would like to see a built in cylinder collider.
     
  10. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Hi,

    Have you tried to delete the default capsule collider on the cylinder gameobject, and add a mesh collider instead?
     
  11. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Hozgen90, arfish and Geckoo like this.
  12. kpm25

    kpm25

    Joined:
    Aug 4, 2021
    Posts:
    2
    .Why can't I just use the primitive Unity Cylinder as parent and add a mesh collider to this primitive cylinder shape??