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 chronicfail · Jul 31, 2013 at 06:02 PM · raycastperformancelayersmeshcolliderhit

Mesh collider as bullet hit detection performance

I am making a first person shooter for PC and possibly web player, with a lot of objects in the scene at one time.

I am using sphere/box/capsule colliders for the physical collision detection as I have read that they are faster than mesh colliders. But for detecting bullet hits (raycast and rigidbody) this won't be precise enough, and really I need the precision of a mesh collider. I am thinking of putting mesh colliders on everything that is meant to be hit by bullets, and putting these colliders on a seperate layer that only collides with projectiles.

Will this have a large affect on performance? I know mesh colliders are slow but surely if it is only colliding with one layer the physics engine will have a lot less to do each frame? Also, as a lot of these mesh colliders will be on rigidbodies, will that make a difference?

So, please could someone answer these three questions:

How much will a lot of mesh colliders affect performance?

Will putting the mesh colliders on a layer colliding with only one layer (or even no layers, as I could easily make the projectile weapons use raycast instead) improve their performance?

Does it matter if a mesh collider is on a rigidbody?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Lovrenc · Jul 31, 2013 at 06:11 PM

Well you can allways go and check how game would behave with mesh colliders and then return back. But beware, autogenerated mesh colliders will not necessarilly be "precise".

That said, i don't know if this changed, but at least all old FPS never used mesh colliders and i doubt you noticed it. Look at quake 3 hitbox. It is not very representative of a character yet i doubt you can really notice:

quake 3 hitbox

Here are some other examples. A little more precise from other games.

Hitboxes

Comment
Add comment · Show 6 · 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 chronicfail · Jul 31, 2013 at 06:20 PM 0
Share

Thank you for answering so quickly,

I will go and check with mesh colliders, it's just that I don't really have enough objects in the game for it to make a big difference. I'm not using mesh colliders for player collisions though, just for detecting bullet hits. For normal collisions I am just using normal colliders. Will this make a difference, or does the layer collision matrix not have an effect on performance?

avatar image Lovrenc · Jul 31, 2013 at 06:24 PM 0
Share

Of course it has an effect. It is like a filter so it reduces load if used properly.

What do you mean exactly by: "for detecting bullet hits"?

avatar image chronicfail · Jul 31, 2013 at 06:24 PM 0
Share

In the picture you posted, would those hitboxes be used for detecting bullets, or just collisions?

avatar image Lovrenc · Jul 31, 2013 at 06:26 PM 0
Share

For both.

avatar image chronicfail · Jul 31, 2013 at 06:26 PM 0
Share

That helps a lot. So using mesh colliders that don't actually collide will make them a lot faster. So all I need to know now is how using these non-colliding mesh colliders with rigidbodies would change things.

Show more comments
avatar image
0

Answer by rokyed · Aug 16, 2013 at 03:20 PM

You can also take a look to Counter Strike Source or Half Life 2 hitboxes : they look like thisalt textalt text

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

17 People are following this question.

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

Related Questions

Raycast hitting the incorrect layer 2 Answers

The Child Is Not Hovered When Passing The Parent's Collider 0 Answers

How to prevent mesh to not go through other meshes 1 Answer

What are the hit coordinates from raycasting? 1 Answer

How to detect raycast exiting 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