- Home /
MeshCollider vs. anyOtherCollider
What might be good combination for situation like:
SpaceShip, thePlayer (1300 poly, meshCollider,convex) SpaceShip, theEnemy (1300 poly, meshCollider,convex) Surroundings, total 40-100 per level (each 200 - 2000 poly, meshCollider) Bullet (capsuleCollider) Flamer (particleCollider)
Documentation says: "The typical solution is to use primitive Colliders for any objects that move, and Mesh Colliders for static background objects."
And: "Convex Mesh Colliders are limited to 255 triangles."
So, my ship got 1300 triangles, but i do not get any error messages for using convex option. Does 255 tris actually mean calculated convex tris, not original amount of triangles (1300)?
Main question: Not sure what to ask :) but i guess.. Should i replace convex meshCollider from player and enemyship with multiple primitive Colliders? If so, how many primitive colliders is ok to use, 10, 100, 1000?
This setup works pretty well at my computer, but could this cause some problems with other computers?
Answer by Eric5h5 · Nov 14, 2012 at 09:03 PM
but i do not get any error messages for using convex option
Maybe you missed it; if you attempt to click the convex box for a mesh collider with more than 255 triangles, you get an error in the console that says "The hull has more than 255 polygons. This is invalid."
Should i replace convex meshCollider from player and enemyship with multiple primitive Colliders?
Yes, if you can get a reasonable collision shape with as few primitive colliders as possible. It wouldn't make any sense to use 1000; in that case it would be slower than a convex mesh collider. Note that you don't need to use the same mesh for collision that you use for display.
Thanks. Now when i look the ship in unity with wireframe view, with and without convex, i am actually pretty sure i can do even better with primitivs than meshCol with convex option. But i cant get no error msg to consol when clicking convex on/off, playmode, build.. I checked also player and editor logs. I also made empty scene with only camera and the ship$$anonymous$$esh. Stat window: Tris:456. $$anonymous$$y script: 1368 ( print( GetComponent($$anonymous$$eshFilter).mesh.triangles.Length ) ; ) And believe or not, i tried to count triangles in unity editor wireframe view :) and now i am sure there is more than 255, no way 1368, but perhaps 456 is pretty close. Any toughts of that?
I went to smoke cigaret, and i understood 456x3 = 1368 :) No idea what, why and.. Edit: "The array is a list of triangles that contains indices into the vertex array. The size of the triangle array must always be a multiple of 3." I guess that explains it. Still no idea why..
Is it possible for you to also make a very low-poly version of your player and enemy ships and then use that mesh for a mesh collider?
I guess that is one way to go. I need to ask graphdesigner to do that, unless there is a way to open fbx file in blender? I know it is exported from Blender, but still, i couldnt open it.
Blender can't open .fbx files.
Primitive colliders are usually the best to go with as long as you're not using too many and you're able to somewhat match the shape of the mesh.
But if you need the colliders to closely match the shape of the ships, a reduced poly model with mesh collider may be an option.
Your answer
Follow this Question
Related Questions
Problem with convex Mesh Colliders 0 Answers
Mesh Collider HELP - 1 Answer
Too many colliders? 0 Answers
A question about collisions. 1 Answer
Can I catch "Gu::ConvexMesh::loadConvexHull: convex hull init failed!" error? 2 Answers