- Home /
Can you apply gravity on the Z-axis instead of Y?
I'm translating a 2D card game to Unity. It will have a fixed, 2D-like perspective, but I will be using the 3rd dimension for some aspects like stacking cards or dropping one on the table from a particular height.
Does it matter if I lay out the table so that it is laying down on the Z plane, or could it also be "standing up" vertically so it's surface is on the XY plane?
Coming from a 2D game, I'm used to the latter, where the table dimensions are on the X and Y axis. But out of the box, this would mean gravity would apply in a dimension parallel to the table surface, not perpendicular to it. Can I simply change that? Does it matter which axis I lay out the table on?
Answer by robertbu · Feb 27, 2014 at 09:40 PM
Assuming you are using 3D physics for this game, you can leave your table on the XY plane and modify gravity in Edit > Project Settings > Physics. There are a few other places in Unity that assume 'y' is up (like Transform.LookAt() and Quaternion.LookRotation()), but they have optional parameters so you can make the change to another axis being up.
P.S. Your title is misleading. Gravity is by default applied on the 'y' axis. If you present your table on the XY plane, you will want your gravity to be applied on the 'z' axis.
Thank you, exactly the specific answers I was looking to have confirmed! I've edited my title - you are correct. 3D can get confusing. :)
Your answer
