Probably a stupidly obvious question, but how do you go about making a 2D game in Unity? By which I mean, do I rotate everything except the camera by 270 degrees around the X axis so that it is all X,Y. Or do I leave stuff unrotated, but rotate the camera itself, and have the game be X,Z? Using Orthogonal view. I'd expect 2D to be in XY, but having to rotate everything seems a rather clunky way of doing it. What am I missing? Thanks.
I don't think it matters, but personally I think it'd make the most sense to adhere to the world axes based on your game. I wouldn't rotate anything, and point the camera towards the game being X, Z if it was a top down game, or X,Y if it's a sidescrolling game.
I use Z as pointing at the player, and X is left/right from camera view and Y up/down. Just build your scene on one axis.
This. In Unity by default Y is generally expected to be "up", so I'd set my game up so that my logic matched with that. As in, I'd make +Y the direction that a character would jump in. This way things like Vector3.Up make make sense.
I wasn't clear unfortunately but I'm planning on a top-down rather than a side-on. Thus having "y" for "up" makes little sense - that should be z. Though of course Vector3.forward (z) would then actually go "up". Hence you can hopefully see my confusion. I'll just change the camera and use x,z I guess. Cheers.
Why? You're basing a pretty fundamental design decision on the happenstance default orientation of the camera. Which way is "up" as far as your characters are concerned? If one of your characters was to be lifted off the ground, which direction would they move in? You should set up your scene such that that direction is +Y in the scene. If 'up' in your game should be 'towards the camera' then it makes sense to set up the scene (including the camera) based on that - so the game plays on X/Z, the camera is positioned somewhere in +Y and is pointed down -Y, such that it is in fact supporting the 'top down'ness of your game. But also, I have a feeling that when you say "up" you're thinking in screen space, where I'm thinking in scene space.
Y is up regardless of what the dimension or position of the camera, 2D, 3D, don't matter, top down, side-scroller, don't matter. Y is always vertical. The position of where you build things in your level is what matters. It's the camera that changes between 2D, 3D etc, not the physics. Up means the direction the character's finger would be pointing if he was pointing upwards in respect to himself, not the screen. If it's a top down your camera used the x, z to move and y would be zooming in and out, if it's a side-scroller then the camera is using the x,y and z would be zooming in and out.
It's a matter of personal perception. In truth, the player will never know the difference. What they see and experience will be the same no matter what theoretical plane it is moving along. In this scenario, what is most important is what you, the creator, perceives. If it seems logical to you, than it is correct. Everything after that is just a matter of consistently applying whichever orientation you go with. Personally, I prefer to keep things locked to the XY axis, and reserve the Z axis for depth from the camera. (and in orthographic cases, sorting) It makes it easier for me to compare screen space with game space. (since the final rendered screen is going to be 2D no matter what)
I also (at least in my platform controller) make increasing X = moving to the right of screen = Vector3.right. This just makes a whole lot more sense in a 2d world, but it also means you need to look from the "back" view in the scene (because in 3D typically transform to the right means move to the objects right which moves it to the left of screen).
This. Also keep in mind that by default all physics actions are axpecting to be Up in the positive Y-Axis. So if there's supposed to be any physics in your game then rotating your whole scene will very likely induce headaches very fast. I'd say: just keep it logical.
Depends on what you're going for. In my case, In my side-scrolling scenes, my camera has rotation (0, 0, 0) - by default this means it's looking at XY axes, with Z determining depth. My game is a bit of a one off since I'm mixing 3D and 2D - I use a perspective camera since that's something I make use of in my game. However, for a true 2D game, you would use an orthogonal camera. In short: whatever type of camera you're using, at least in Unity you shouldn't have to make any awkward rotations to make it work. If you're asking about Blender, on the other hand, I've found that the orientation of the object has to match the coordinate system, which makes things rather interesting. But, you're asking about 2D...so, I'll assume you're not.
In the context of Unity, Y is indeed "up". Seriously, go print the value of Vector3.up. Nobody's saying that this is some kind of universal mathematical truth. The point is entirely that you may as well work with your tools instead of against them, and in Unity and its APIs the convention is that +Y is up. Doing something else is certainly possible, but it will make life some degree more difficult.
Ooooohhh. Lok I can even set it myself in modo: So what's your point here? In Unity Y is Up and you can't just compare that to any other 3D app.
+1. 3ds Max's Feedback section looks just like Unity's. Did Unity copy them, or did they copy Unity? :-?
A default camera, in an empty scene will be at -10, on the z axis. As Fishman said, x is left/right, Y is up/down, and +z points toward the player/objects. This seems to be easiest to mix 2D and your UI without having to do funky maths in your code everywhere. Also, for 2D, set your camera to Orthographic and set the ortho size to 1/2 the height (so 384 for a 1024x768 game) - which means 1 unit of pixel dimension equals 1 unit of x/y making it easier to keep your UI 2D objects in sync. Gigi.
Building on the XZ plane might be a better idea if you plan to use Unity's NavMesh for pathfinding. The NavMesh generator always uses the XZ plane.
Anyway, they should really find a standard between they all (and leave the option to choose the legacy mode), not only the coordinate system but the measurement system too (thank David Unity looks a lot like Maya).
Positive X is forward in a 2D game, negative X is backward, positive Y is up, negative Y is down, and Z is irrelevant. Z should always be set to zero in a 2D game. Once Unity 4.3 comes out we won't have to worry about any of that any more though.
I've never had a problem with the Y Up or Z Up distinctions, as it's really quite arbitrary. Euler angle ordering is also arbitrary and you can get pretty confused if you don't match systems. But I really wish all products used a right-hand coordinate space. Microsoft really made a stink when they chose left-handed coordinates for DirectX, all these years ago, even after SGI GL and most other CAD used the textbook math-and-physics-tradition for years. It was done as a sort of lock-in move, and here we are years later having to work around such distinctions between products.
I thought it was funny that Unity added a Quad primitive in 4.2, apparently to support 2D somewhat, but they rather bizarrely generate it on the X-Z plane which is NOT the most common plane for 2D games and makes no sense unless you're doing a top-down thing.