Colliders Intersecting

Hoping there’s a solution to this, I request your help on the following issue.

First of all, I should let you know that I’m a newbie. I started learning Unity about 2 weeks ago mostly by clicking on each button to see what it does. So if this has a simple solution that I haven’t though of yet, I apologize.

A couple of days ago while browsing the forum I ran into the http://unity3dstudent.com/ topic and I tackled the first challenge after learning all the modules. I ran into a problem however, my colliders seem to intersect each other and slow down the movement progress (as if I had a material with high friction).

Already tried a new project with new gameobjects as well as reinstalled Unity but nothing seems to work. If there’s something I overlooked, please let me know! It’s giving me headaches already. :slight_smile:

Here’s a video to better explain it:

Have you changed the Bounce Threshold, Min Penetration For Penalty, or Solver Iteration Count?

I poked my nose in there too, didn’t think it would have anything to do with it but I tried different values and nothing seems to work. Also reseted to default and I get the same results. :frowning:

Can you upload the unitypackage?

Here it is:

http://www.mediafire.com/?r3lmatkkzy8tfqa

I have redone the scene at least 4 times now so it might not behave exactly like the one in the video but it should have the same problem with the colliders.

The empty gameobject “player” shoots the box so you can move that around and see how the boxes interact with the floor from various angles and positions.

Thanks for looking into this. :]

later edit:
I should mention that lowering the gravity value in the physics settings (from -9.81 to -5) does indeed make the box bounce more and resemble the challenge video.
The colliders are still intersecting though and I was hoping to not have to resort to changing the overall gravity if there are other ways to go around this.

I did more tests and I also noticed that the “Min Penetration for Penalty” value helps a little (reduces the intersection area). I can’t give it the 0 value because then the boxes bounce for a few seconds until they finally settle, again by intersecting with a small area of the floor.

Is it possible to reduce this intersection completely or just minimize it as much as possible? I’m not really sure how physics engines work. Never had to deal with them in Maya.

I checked it out. There’s no problem with your result. If you want less penetration, you just need to lower Min Penetration For Penalty. However, the reason that the box behaves differently in the video, is that they’re using a “bouncy” physics material. (See screenshot below from their video.) I didn’t see this in their videos (but I didn’t watch all of them), so if they don’t actually go over it, you should probably tell them to redo the videos or add information.

Aside from making a bouncy material, setting it as the default physics material, and adjusting the box’s force value, here are are some changes I made to your project:

AddForceZ:
AddRelativeForce instead of AddForce, which I think is more intuitive here.

Take out unnecessary multiplication. (While this is an optimization, it won’t be noticeable with only one object. :wink: Still, this is good practice, and the way they showed how to do it in their video.)

ForceMode.VelocityChange, because the default, Force, is really only handy for moving things over time; it’s not geared for instantaneous velocity change like you want. You can change it to Impulse if you want the mass to be taken into consideration. (I saw that they didn’t do this in the video, which isn’t good practice, but might have been seen as overly complex for a beginner tutorial.)

DestroyWall:
GameObject.Find is slow, and unnecessary. theCollision.gameObject is a much better method.
I didn’t see a reason to delay the destruction by .1 seconds, so I took that out.

388440--13364--$screen_shot_2010_09_17_at_63246_am_859.png
388440–13365–$bouncier_799.unitypackage (11.1 KB)

Ok thanks for all the info. It’ll take some time getting used to all the tricks I guess. :slight_smile:

I wonder, are you using Unity 3?

I’m using the indie version 2.6 and getting strange results with the scripts from your package. The box just flies off the screen (through the wall without destroying it) in less than a second.
More than that, the scene, box and physical material are not recognized so I used the scripts in my own package.

I’ll take a look into AddRelativeForce and ForceMode.VelocityChange but they do seem a bit over my knowledge level.

As for the delay, if I had none, the box would destroy the wall and go through it without colliding. Had to put that in so it was gonna bounce off the wall first.

edit:
I’m getting much better results when combining a low “Min Penetration for Penalty” setting with a bouncy physic material. Thanks for that tip. :wink: