View Full Version : Collision problems
02-10-2012, 08:32 PM
I'm working on a senior project, and we chose Unity to run our level. We are having serious collision detection issues with all the meshes we try to import in from Maya. I don't set up any previous collision in Maya before exporting with the FBX format. Unity ships with a collision creator for static meshes so it seemed simple enough.
I'm using Maya 2012, and the latest version of Unity. Has anyone else had issues with Unity's mesh colliders? Also, most answers I've been finding from Google are suggesting people are writing their own custom scripts for collision detection, is that normal?
02-10-2012, 08:46 PM
the mesh colliders can be quite sporadic when combined with certain other built in colliders, check out this list at the bottom of the page for some info
02-10-2012, 08:50 PM
I recently built a racing game with Unity, and there's some tricks to collision in Unity.
Firstly, if you want two things to collide well, one has to be marked as convex. This option should be under the collision information section on the object in the inspector. For our game, we had the cars as convex (this means no holes or scalloped out bits, think of it as if you wrapped it in lycra), and the track and terrain as not convex.
Complex colliders, for example guns, can be made out of a bunch of basic collision primitives. The box collider is very fast, and you can have a bunch of those all attached to the gun to make a rough gun shape and it'll work.
Apart from that, it's very simple in Unity. Just make sure you add a box/sphere/pill/mesh collider (component>physics>...collider).
In the settings somewhere you can change physics timestep, max setps, and collision layers. Don't mess with these unless you know the consequences of messing with them, and you will only know the consequences of messing with them by messing with them. At least do it on a build you can (and will) throw away.
02-10-2012, 09:06 PM
Our game that we are creating involves a single player character running around in a pseudo-side scrolling environment. The camera can sometimes switch to a more over the shoulder view at times.
The only things that will be colliding of note will be the character when she runs into environment objects, and monsters if we keep our combat mechanics.
Thanks for the responses though, it might be the fact that we were using a simple pill for our Alpha presentation which doesn't accurately reflect what our character will be in terms of collision.
I've tried adding different kinds of colliders to a mesh to see if it gets detected, and none were working. We'll keep poking at it this weekend though. If I have a breakthrough I'll post what I do.
02-14-2012, 05:02 PM
I think you need to make sure your environment is marked as "static" as well.
02-14-2012, 06:10 PM
I've seen that checkbox on individual assets, but are you talking about the environment as a whole? I have no idea where that would be marked.
02-14-2012, 06:27 PM
Are you talking about a terrain mesh? or a mesh build in an external application and imported into unity. If its the latter, you can select all of the parts or even just the parent object and click static, and it should ask if you want to also apply it to the rest of the childen objects.
02-14-2012, 08:38 PM
Just individual static meshes, built in Maya, exported as FBX into Unity. I'll have to check off that box this weekend, but we have major modeling to catch up with so who knows when I'll be able to test out those different boxes again.
02-20-2012, 04:13 PM
what exactly are your collision issues are you falling through the floor ? getting stuck ? not moving with animated objects like doors/elevators ?
in gemeral :
never have a mesh collider vs mesh collider collision
your main character should remain a capsule dont make cubes for individual limbs and than expect the animations of those limbs to have any effect on the colision/locomotion of your char if the characters arm reaches out it will reach through a wall regardless of what the colliders say
under some circumstances collisions become more reliable when you attach a rigidbody remove the gravity flag and set it to kinematic
important physics objec/rigid bodys that are not just for visual detail but have an effect on game play should be set to continues dynamic !
02-22-2012, 07:11 PM
The collision problem is the character doesn't correctly collide with anything we import in from Maya. The character will fall through the floor, not correctly hit a table, go through the wall, etc.
02-22-2012, 08:39 PM
I'm sure you are, but just to be clear, you're checking generate mesh colliders on import?
02-22-2012, 08:56 PM
02-22-2012, 10:05 PM
I also once had an issue of my controller falling through colliders, I believe recreating the controller solved it... just throwing out ideas!
02-23-2012, 07:08 AM
Thanks jolyjewsus, I'll let my team know today when we meet. I'll probably do some trial and error this weekened if I have time.
02-27-2012, 05:12 PM
increase the skin width of the character controller above 0.1 !
02-27-2012, 05:17 PM
Warby, I actually was able to do that last weekend, and it did help a lot. We are just moving a head with what we have, and our static meshes are going to be used just for decoration. I'll post some screenshots when we are finally done in 2 weeks. I'm so ready for Spring Break.
Thanks everyone for all the tips and suggestions. This has really been a learning process tackling a new engine.
vBulletin® v3.8.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.