1
\$\begingroup\$

I'm trying to get my first 3D game done with Unity. In this game the character will be flying through some rings.

I made the ring asset with MagicaVoxel, exported it in .obj and reimported in Unity withouth problems. I've set a rigidbody and a box collider on the character model and a mesh collider withouth rigidbody to the ring and I've also set Convex and added the default mesh of the ring.

The problem is that whenever I try to go inside the ring, I can't because I collide even with the empty part inside it. I'm not sure on how to made Unity collide only with the external part, but as far as I can see in the editor I'm using, I've no setting for it. I'm using Unity 5.3.4f1.

Can someone please explain me how to solve this problem?

Thank you very much.

EDIT

I'm sorry, I forgot to mention that I'm aware I can unset the ring mesh Convex property and get it to work. The problem of this solution, though, is that whenever I put adjacent rings I can glitch through them even if there's no space to fit. So basically I need a solid collider with Convex only on the external part of the ring and with empty space to fly through on the inside. Is this possible somehow?

\$\endgroup\$
1
\$\begingroup\$

Unmark convex on the mesh collider. Convex mesh colliders will NOT have holes in them because that is required, by definition, to make them convex. Non-convex mesh colliders are only supported on kinematic rigidbodies and objects without rigidbodies, which should be fine for your usage.

\$\endgroup\$
  • \$\begingroup\$ Thank you for your answer. I've already figured out myself that this would work. The problem in this solution, though comes when I try to put more ring models one after another. If the mesh collider is not convex, I can glitch between the rings, even if there's no real space between them and I shouldn't be able to... \$\endgroup\$ – Aurasphere Apr 2 '16 at 15:28
  • \$\begingroup\$ Consider making collision meshes and visual meshes different. This is a very commonly used trick in games for both performance and quality reasons. If you have a long row of rings, maybe you could make the collision mesh a single extended ring shape. \$\endgroup\$ – Raymond Lin Apr 2 '16 at 20:22
  • \$\begingroup\$ I could do that but the game uses random terrain generation, so I don't know how many rings would be in a single row... \$\endgroup\$ – Aurasphere Apr 2 '16 at 23:56
  • \$\begingroup\$ Maybe, instead of instantiating rows of individual rings, make one ring by itself a prefab, two rings together another prefab, three together another... etc. and instantiate these row prefabs whenever you have two or more closely positioned rings. This may end up restricting how "randomly" your rings are spawned, as obstacles are all pre-made, but it may be worth it if it helps fix your collision issues. \$\endgroup\$ – Raymond Lin Apr 3 '16 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.