Many 3D games are actually need only 2D physics (especially 2D collision test). I guess It would gain a considerable speed-up by replacing physX with the 2d candidate If physics computing is the bottleneck.
However, it is not easy in unity 4.3. For instance, given a gameobject attaching a Rigidbody2D and CircleCollider2D compontent. The 2D physics will automatically update the gameobject’s x y coordinate, i.e. map (x, y) to (x, y, 0).
But we are used to make y coordinate as the “height” dimension in unity. For instance, it’s very easy to rotate by y cooridate in unity editor, on the contrary rotation by z cooridnate is terribly hard.
So My ad-hoc solution is to keep two group of gameobjects in the world. One (empty gameobjects with only physics component) plays the 2d physics behind the camera. The other (with everthing visible) maps (x, y) to (x, 0, y) so the player can see the resulting world.
My question is, can we find an elegent solution to this problem? Or my consideration is insignificant(replace PhysX with box 2d won’t improve the performance)?
I understand and agree. The real request, in my mind, is to provide an option for physics to work in the XZ axes instead of XY. If you have a normal 3D game but no colliders are stacked one above the other and do not move in height (eg. Pushing around boxes on the floor) all you need is 2d physics.
The reason I want this ability, though, is for 2D games that work better on the XZ axes (eg because they use a NavMesh)
As dasbin said, My question is how to cooperate physics2D with XZ plane rather than XY plane in unity.
Some 3D games like Warcraft3, LOL are in fact computed in a 2D physics world. My project is under similar situation.
You can always just say Y is forward and use XY as XZ, except possibly for NavMesh stuff (which I’m not very familiar with), which would be far easier than remapping axes.
Yes, I’d tried this method. However, It also has problems. For example, It’s very hard to control the scene(especially rotate the scene along Z as up) in unity editor if Z is up.
I had the same issue… I wanted to use Box2D physics and was all excited… and created one collider and instantly noticed… oh… it has to be on the XY plane. How many games are on the XZ plane? Probably a ton.
I spent a good amount of time converting the orientation, physics, scripts, camera, player controller, etc. over to use XY as the ‘base plane’ for the background. It took a long while, but I managed. The most annoying aspect was trying to figure out how to rotate the camera correctly in the fashion I wanted.
It works, yeah… but why isn’t there an option to say, “Use XZ plane for 2D Physics” or something. Seems… silly. They are just numbers after all. It was quite annoying.
… and of course every other asset that seems to think XZ is the default setting for a 2.5D or 2D type game that isn’t a sidescroller is broken now as well. Apparently the thinking was XY was only for scrolling games, and XZ was perfect for 3D-esque 2D games. Thanks Box2D, you made my week.