I’m in the process of learning Unity.
Simple scenario: A sphere drops and collides with a plane. Works fine…generally.
Collision detection fails, however, when I scale the sphere down to 0.05 units (roughly the size of a golf ball if you take the default physics setting of -9.81 to be in meters/s^2). The ball drops right through the plane and keeps going.
I used a box instead of a plane and things worked better but the ball goes about halfway into the box before stopping.
I could scale everything up to get around this but then, of course, things are going to appear to accelerate too slowly (for the type of game object I want to model).
Is there a setting on the game objects or in the physics settings that will correct this problem?
Is there a doc or tutorial anywhere that addresses these types of physics related issues (scaling)?
Thank you.
In the physics settings (menu: Edit > Project Settings > Physics) you will find a setting called Min Penetration for Penalty. This is the distance by which two colliders must overlap before a collision is registered and a “penalty” force is applied to push them apart. You will probably need to reduce the size of this parameter if you are using very small objects. Also, as you have discovered, a non-convex mesh collider (like a plane) is very thin and more susceptible to this problem than a primitive collider.
Thanks. I tried reducing min penetration to no avail.
The problem appears to be if the object too small and is moving too fast, the collision won’t be detected. A sphere 5 cm in diameter dropped from a height of 3 meters will stop when it intersects a plane. Drop it from 5 meters though and it goes right on through.
Another odd thing: Using the project defaults, g = 9.8 m/s^2 etc, drop a sphere (1 meter in dia) from a large height (e.g., 400 meter). The sphere appears to stop accelerating once it reaches a certain velocity (terminal velocity), even though drag is set to zero. What’s up with that??? Why doesn’t it continue to accelerate at 9.8m/s^2 until it impacts the plane???
Hmmm. Scratch that last comment. It does, in fact, appear to be accelerating throughout the drop. Was relying on visuals rather than actually measuring the time.
I have a fun sample here (really small) of a spheres passing through even THICK cubes, based on their speed:
http://www.createdbybrett.com/Unity_sphere_through_cube.html
This demonstrates (I think) that it’s just the relative speed of the ball, relative size of the ball, and relative thickness of the thing it’s hitting or supposed to hit. In other words, I don’t think the problem is that the moving object is small. It’s all relative.
(There’s a 3-page post about this at http://forum.unity3d.com/viewtopic.php?t=5793 .)
<< just the relative speed of the ball, relative size of the ball >>
Agreed. With default settings and “normal” object sizes, it’s simple enough to get a sphere to pass through an object. The problem is that it doesn’t seem to be possible to get things the size of pool balls and marbles to behave and move like pool balls and marbles unless you really restrict their speed.
I’ll take a look at the link. Thanks!
Thanks for the link, BrettFromLA. I tried the suggestion to increase the physics frame rate (which I assume means reduce the setting “Fixed Timestep”). I knocked that down to 0.001 and I can now have my small objects moving and accelerating (gravity is at 981 cm/s^2) much faster and things look and behave as small objects should.
Just to note, Unity 3.0 has new options for the rigidbody component that will avoid this kind of problem.
Thanks, Andeeee. I was under the impression based on the post by Quietus in the following thread that it would still be necessary to increase the Phys framerate in 3.0:
http://forum.unity3d.com/viewtopic.php?t=5793&postdays=0&postorder=asc&start=30
“PhysX does not like tiny objects. You want to try and normalize everything according to Unity’s default scale. This won’t change in Unity 3.0.”