Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Pangamini · Aug 08, 2012 at 01:09 PM · collidermesh colliderbakeconvex

mesh collider instancing

I have noticed that creating a complex convex mesh collider produces a significant lag, even if i am instancing the same prefab with the collider multiple times. It looks like the concave->convex procedure is called for every instance. My question is if it's possible to pre-build(runtime) or bake(in editor) a convex mesh for mesh colliders so it doesn't have to be generated every time a collider is instanced.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kryptos · Aug 08, 2012 at 02:37 PM

The best solution would be to NOT use any MeshCollider. The computation of the convex collider (convex hull closure) can be very expensive. And the resulting collider will also be very expensive.

My advice: create a compound collider with the primitive colliders (Box, Sphere, Capsule) and make a prefab with it. This will take a little more time during editiong, but will have much greater performance at runtime.


A quick (and also not 100% perfect) explanation to why MeshCollider are so expensive.

First, let's explain why the primitive collider are so cheap.

  • a BoxCollider just checks for bounds, so it is like using the < and > operators a limited number of times.

  • a SphereCollider is just a check for a distance from a point, which is not very expensive. It can be further optimized by using the squared distance (which is the case in most implementation).

  • a CapsuleCollider is also a distance check but along a line. So it requires first to project onto this line.

Therefore, the order of collider is (cheapest first): Box < Sphere < Capsule.

Now a MeshCollider is just a bunch of triangles. The engine has to check each triangles against collision. Thus: MeshCollider >> Capsule.

With a convex collider, there are some optimizations (not presented here). But basically in the worst case, the physics engine still has to check each triangle.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pangamini · Aug 08, 2012 at 02:41 PM 0
Share

Thanks for your reply. I do have some experience with other physics engines and i know what benefits the primitive colliders have, but let's say i have to use mesh collider and my mesh is already convex. But unity is checking and recalculating a convex mesh for every single instance of prefab, which is very laggy. Is that really necessary? (runtime performace is good since mesh to mesh pairs/collisions are rare)

avatar image Kryptos · Aug 08, 2012 at 02:51 PM 0
Share

It seems that the generated mesh is not shared. There might be a design explanation, but this is beyond my skills and knowledge of Unity

Try to ask the Unity support. $$anonymous$$aybe this will change in the future. Ideally, it would be great to be able to flag a mesh as being convex so that recomputation is not necessary.

avatar image Pangamini · Aug 08, 2012 at 02:57 PM 0
Share

There's a flag "generate colliders" in the importer, but i don't see any performance boost

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Bucket with apples on a terrain (Sphere Colliders + Mesh Collider + Terrain) 0 Answers

Adding multiple simple mesh colliders to be able to click on an objects parent 0 Answers

Pushing a mesh with mesh collider 1 Answer

Preventing Convex Mesh Colliders from Interpenetrating 2 Answers

Object with more than 255 polygons (with Mesh Collider(Convex - on)) is falling through a Terrain 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges