Forcing physics to ignore 3rd dimension

Working on a top down 2d game with lots of 2d and 3d physics collisions happening.

Imagine playing cards being moved around on a table. Many will overlap bumping “up” into the 3rd dimension.

This large amount of collisions (large number of objects) is bring the simulation on the iPad down to it’s knees.

Is there anyway to force the physics engine to ignore any calculations for the 3rd dimension?

The goal is (from the example above) that the cards would never over lap but just have their edges bump against each other.

Hope that makes sense. Thanks.

Use rigidbody constraints, where you would use freeze position Y, and freeze rotation X and Z. I doubt that would have much effect on the framerate though.

–Eric

How are you “dispensing” the cards? You could write your own collision detection. One way to do this (the obvious way) is to check the moving card’s edges against all the edges of the existing cards. The other way is to create a 2D array representing all the cards on the table. You start by clearing all the values to zero. Each time a card is placed you set all the values of the area of the card to 1. Now when the next card is dealt you check the area the card is moving into. If it’s non-zero, the card stops.

I’m not sure I understand what you are doing enough to help.

Sounds to me you actually want playing cards to not collide with each other, is that right? if so then you need to set up your collision layers: http://unity3d.com/support/documentation/Components/Layer%20Based%20Collision%20detection.html

Physics speed gains:

  1. clever use of layers to minimise what kind of objects bother checking others (http://unity3d.com/support/documentation/Components/Layer%20Based%20Collision%20detection.html)

  2. lower your iteration solver count (Unity - Manual: Physics)

  3. lower the framerate of fixedupdate (Unity - Manual: Time)

Calculate this by 1.0/30 for setting the rate to 30fps. Turn on Interpolation for all rigidbodies so it looks smooth regardless of physics update rate.