Before updating to Windows 10 you may need to return your Pro license. More information here

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?

more ▼

asked Jul 31, 2013 at 06:02 PM

avatar image

213 24 32 34

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.


more ▼

answered Jul 31, 2013 at 06:11 PM

avatar image

3.8k 7 13 26

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?

Jul 31, 2013 at 06:20 PM chronicfail

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"?

Jul 31, 2013 at 06:24 PM Lovrenc

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

Jul 31, 2013 at 06:24 PM chronicfail

For both.

Jul 31, 2013 at 06:26 PM Lovrenc

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.

Jul 31, 2013 at 06:26 PM chronicfail
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Aug 16, 2013 at 03:20 PM

avatar image

31 8 8 9

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Jul 31, 2013 at 06:02 PM

Seen: 1366 times

Last Updated: Aug 16, 2013 at 03:22 PM