- Home /
Colliding 2 completely flat quads with physics?
Imagine you have imported 2 completely flat 2d quads from some 3d app and they are now in the Unity scene, positioned so that you're basically looking at them as two squares on the screen side by side, not necessarily touching.
Now, with Unity's physics (colliders, rigidbody, whatever), if I push one of those quads horizontally toward the other quad so that their edges would collide, will it actually collide or will they pass right through each other?
My concern is that the quads have no depth
and therefore they won't collide? ie I guess the physics system cannot do proper 2d you have to always have some depth to your objects to make them collide?
I should clarify that obviously you need to add some kind of physics collider/rigidbody to do any colliding... but my point is, will they collide as completely flat objects if the colliders are flat?
@ImaginaryHuman, should you return, please checkmark the right answer, thanks.
Answer by duck · Apr 20, 2010 at 09:40 AM
No, you can't have completely flat moving physics objects (rigidbodies).
You can have completely flat objects which act as Static Colliders - for example, a ground plane which doesn't move. To do this, you would just have a plane with a collider component but no rigidbody component attached.
However, if you have a completely flat object (eg, unity's built-in plane), with a Mesh Collider (so that it uses the objects mesh as the collision volume), and you try to add a Rigidbody component, you will get an error from the physics engine.
This is because the rigidbody needs some volume in order to have mass, inertia, and these things are impossible to compute if the rigidbody has no volume.
If you assign a Box Collider to a game object with a completely flat mesh, the box collider will automatically give itself a tiny amount of depth so that it performs correctly.
Thankyou Duck, this is a great answer, thanks for the clarity and detail and especially the explaination of why
this is the case.
Answer by Cosmin · Aug 06, 2010 at 11:13 AM
I have same problem i need to have collision bettwen particles in xoy plane and a 2d map also in xoy plane but i can not find a way to do it... if u got any solutions that oyu can share it will be good
See the above answer from Duck. Unity has kind of two aspects to its collision detection system, one is the collider, the other is the rigid body. The collider can be used to detect that something collided with something else, but not with any reaction
. You need rigidbody for it to calculate a proper reaction. Or at least, that's how it seems to me. Like Duck said you can have a flat plane with a collider, and since the plane doesn't move it works. So it depends if you have moving objects, which you probably do.
You could write your own 2D collision routine if you want it to be simple.. e.g. collide rectangles and simply check if the rectangles overlap and then move the quads manually to simulate physics. But if you want to use Unity's physics then you have to give your objects some volume. Your flat quad has to become a box with volume. So long as you use an orthographic projection ins$$anonymous$$d of perspective you'll never see the sides of the box, just the front. Then the physics engine can collide the boxes properly. You can also use rigid body to make the object only rotate in z with no z movement
Answer by ImaginaryHuman 1 · Apr 16, 2010 at 09:27 PM
So there is no such thing as a flat collider that will collide edge-on, it has to be a collider with depth?
Please don't post comments as answers. It makes baby jesus cry.
Answer by Fathom · Mar 16, 2011 at 03:54 PM
well the colliders are invisible so you can make the collider thicker, anyway way i see it but i get what you saying bu cant say i have tried it and you can make the colliders a faction whider so you wont notice how close they might come,.