Search Unity

Adding a new collider primitive

Discussion in 'Scripting' started by g012, Aug 5, 2009.

  1. g012

    g012

    Joined:
    Jul 29, 2009
    Posts:
    6
    Hey,

    I'd like to know if it's possible to extend unity to add a torus collider, in any way.
    Thanks.
     
  2. Murcho

    Murcho

    Joined:
    Mar 2, 2009
    Posts:
    309
    You could import a torus and use the mesh as a mesh collider. It is a concave mesh though, so it requires a lot more calculations than a convex collier.
     
  3. g012

    g012

    Joined:
    Jul 29, 2009
    Posts:
    6
    Thanks for the reply, but that's exactly what I'm trying to avoid. I'd like to have the primitive so collisions can be fast. It's for IPhone.
     
  4. Murcho

    Murcho

    Joined:
    Mar 2, 2009
    Posts:
    309
    I doubt there would be any other way to have this in there, as all the primitives available in Unity are convex meshes, and the torus is a special case requiring a concave mesh.

    If you're looking for a faster way to build up this collider though, you could build up a compound collider from the other primitive collider types. See here for some info on setting one up. You could build it up from several box colliders, and while they wouldn't be an exact match for the torus, games development is all about cheating :p.
     
  5. matthewminer

    matthewminer

    Joined:
    Aug 29, 2005
    Posts:
    331
    What he said. You can use a ring of sphere colliders to approximate a torus. A wizard exists for doing just this at the Unify Wiki: CreateTorus
     
  6. g012

    g012

    Joined:
    Jul 29, 2009
    Posts:
    6
    Thanks for the replies.
    The script is great. We were already using spheres to approximate a torus, but the script will help us finding the minimum number of spheres required for our case.
    Too bad we can't add primitives with code though.
    Thank you all for the help.