- Home /
rigidbody sphere falls through collider plane
Hi, first of all: I'm absolutely new to Unity (v2.6.1)... I've created a plane and a sphere in Maya (for a simple pinball game I'd like to create in Unity) and exported both as one FBX file (including normals).
In Unity I attached a rigidbody and a sphere collider to the sphere ("use gravity" set to true), and a mesh collider to the plane ("IsTrigger" set to false for both objects). The sphere is placed above the surface. When I hit "play" the ball falls through the plane to infinity. If I enlarge the sphere collider quite a lot (about three times the size of the sphere geometry), it still falls through the plane but keeps hanging under the plane. If I scale the sphere collider even more the sphere falls down and its collider rolls over the surface of the plane (the sphere is of course "floating" in the air - because I expect only the colliders are used for physics calculations).
Any idea what's my mistake?
Can you post the meshcollider? It's hard to answer just form your description.
Answer by Dwair · Jan 16, 2010 at 07:26 PM
Fast movement and/or thin colliders are a real issue when using physics.
You're right, movement is taht fast and there is no interpolate between frames, so an object can pass through another thin object (because their positions never actually collided each other)
You can try to bypass with a raycast collider searching for possible colliders like in the script DontGoThroughThings here:
http://www.unifycommunity.com/wiki/index.php?title=DontGoThroughThings
That script can help a lot with that problem, but is no 100% fail-safe, so try to make colliders as thick as you can.
Answer by Eric5h5 · Jan 16, 2010 at 08:44 PM
Make sure your sphere is somewhere around (1,1,1) in scale. Change the scale factor in the mesh importer if necessary. Having a mesh collider for a flat plane is perfectly fine; this is what the default Unity plane has. But the physics engine does not like small objects.
For a pinball game, I would increase the physics timestep quite a bit so physics runs at least 100fps. This does of course increase the CPU power needed, but a pinball game doesn't have many moving objects so that shouldn't be an issue.
Tweaking the Fixed Timestep value fixed my issue with a sphere clipping through a floor box collider (box collider on kinematic rigid body, continuous speculative, and the sphere with gravity on and CD set to continuous). The exact value I tweaked was Fixed Timestep from 0.02 to 0.014, which was the $$anonymous$$imum value I needed to set in order to get the clipping to stop.
Answer by Lucas Meijer 1 · Jan 14, 2010 at 08:34 PM
I think MeshColliders don't work for totally flat planes. Use a plane collider instead.
$$anonymous$$eshColliders work fine for planes - and there is no such thing as a PlaneCollider in Unity for that matter :)
Answer by drhenry · Jan 15, 2010 at 07:56 AM
I hope you meant by "posting the meshcollider" posting a screenshot of the Inspector view. There you go:
http://www.freeimagehosting.net/uploads/df1ca0f4dc.jpg PlaneInspector
Concerning the plane collider: did you mean the box collider? I've tried to use the box collider instead of the mesh collider but the sphere still falls through the plane (even if I enlarge the height of the box collider, which was originally set to 0).
Answer by drhenry · Jan 15, 2010 at 08:10 AM
Another thing I've discovered: if I place a Unity cube beneath my plane, the sphere falls through this box, if it is scaled very flat, and doesn't fall through it, if the cube is thicker (having a box collider attached to the cube).