Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
5
Question by Peter Alexander · Dec 22, 2009 at 06:11 AM · physicsraycastmeshperformance

Performance of Physics.Raycast

Does anyone know what the relationship is between the performance of Physics.Raycast, and the amount of triangles in a MeshCollider? Will it take longer for more polygons, or is Unity doing some fast, octree culling behind the scenes?

I ask because I have a large terrain with a MeshCollider attached to it, and use Raycast to detect collision with it. However, most of the terrain will never be touched, and I was wondering whether it would be worthwhile to split then mesh into touchable and untouchable submeshes and only attach the MeshCollider to the touchable bits.

The terrain mesh is around 30-40k triangles, and this is on iPhone. And yes, we have determined that this is important for performance.

Thanks in advance.

Comment
Add comment · Show 1
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 yoyo · Jul 11, 2013 at 07:19 PM 0
Share

See my answer to this question for a test script you could use to benchmark performance.

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Brian-Kehrer · Dec 22, 2009 at 05:31 PM

Very large mesh colliders do slow things down, as the physics must internally check against every triangle, sort of - by what ratio it is slower, I am not sure. Of course there are lots of internal optimizations, but you'd have to read up on Physx here

The best way to find out of course is a simple test - create one mesh collider with 40k triangles, and then create 1 with 4k, and check out the performance difference in unity 2.6 with the profiler.

If you can, you might also try using a compound collider with a bunch of box colliders, unless the detail in this terrain is exceptionally important.

I used the CharacterController (which internally does some raycasting) for ExtremeSledding on the iPhone, typically on terrains of ~5k triangles. If the terrain got to around 10k, performance was horrible. I can't imagine you will have much luck with 40k triangles on the iPhone except in the simplest of cases.

It goes without saying, but it would be worthwhile to split the terrain simply for the purposes of culling, if that makes sense in your game. (I assume you already are, and simply kept a single mesh collider?). At around 12k triangles on a 3G (not 3gs...) performance starts to sag a bit for me.

Comment
Add comment · 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
2

Answer by Ben Throop · Dec 22, 2009 at 08:03 PM

For a test, I'd want to have the same number of collision triangles in the scene but have them in more than one collider. That'll tell you if Physx is doing any internal optimization like Bounding Box checking. I hope that it is. :)

Comment
Add comment · 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
0

Answer by spencer lindsay · Jan 30, 2010 at 10:25 PM

I know I'm in late, but you can also create a simplified version of the path you want your player to be able to take through the terrain and use that as collision. Turn off the Mesh Renderer and group it with your visible polygons.

Best Fishes,

Spence.

Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

Call physics api from parallel thread 1 Answer

To detect 'ground' for jumping, is physics.checksphere more efficient than raycast? 1 Answer

BoxCollider vs. RaycastAll 1 Answer

Do Mesh Normals Influence Physics Behavior 1 Answer

Returning list of Triangles, Vertices or Points by raycasting through a mesh (iPhone) 1 Answer


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