- Home /
how to make a plane's height be Y instead of Z
By default, Unity creates planes normal to the y-axis. So that if looking thru the default camera the x-axis can be thought of as the width of the plane and the z-axis is the plane depth.
If I rotate a plain -90deg about the x-axis, this will make no difference as far as scaling goes: x will still be width and z will be what I'd think of now as height of the plane. First I thought I was misunderstanding the frame of reference for the plane's transform and so I created an Empty merely as a parent transform; I added the plane with its transform set to identity as a child of the empty and then I rotated the empty about the x-axis by -90. But still the same result: I have to use the z-axis for the plane's height / width or however we might want to call the other dimension on the plane along with x.
In contrast, this is not the case with a cube object: rotating it about the x-axis by increments of 90deg does alternate between y and z.
So am I missing something or is it just not possible because, say, it was decided that a plane has absolute coordinates?
"Create Plane" mentioned by Robert below, is a really fantastic script - you need it in every project.
"So am I missing something" -- no, it was just "silly" if you will that Unity's basic plane from the old days was "laying down". it's always caused confusion!
Answer by robertbu · Oct 14, 2013 at 02:28 AM
You can use the new Quad game object. A Quad is a 2 triangle plane oriented on the XY plane with normals facing backwards (i.e. towards the camera if the camera is in its default negative 'z' position looking towards positive 'z').
Another solution is the CreatePlane editor script you will find in the Wiki. It allow sfor both horizontal and vertical planes and allows you specify their world size and (indirectly) the number of triangles.
Sweet, I'll check those out. However, does that mean that then I'm right in that planes are set to absolute coordinates by default, as opposed to "regular" 3d objects?
No, planes are like other game object. I'm not sure of your experiment. If you look at the reference for Transform, you will see scaling is 'localScale'. Scaling is defined in local coordinates. So scaling the default plane will always be done using the X and Z. Scaling the Quad will always be done using the X and Y. If I scale a cube on the X, rotation does not change which local axis is scaled.
I meant the final transformation relative to the camera's up direction. A cube with scale (1,2,1) looks "camera" to the default camera. If I add now a 90 rotation about x, the same cube now looks "deep" but no longer "tall" to the same camera. I'd have to now change z (relative to world transform) to make the same cube appear "taller." You are right that the same applies to a plane, but I still think it is a Unity convention that they chose x and z as the orthonormal pair to base the plane off. It could have been x,y ins$$anonymous$$d. Personally, I ended up going for the following setup: An Empty and the plane inside it with its transform rotated -90 about x (now relative to the parent empty's transform ins$$anonymous$$d of to world transform). So if I change the y scale of the parent empty, this maps to changing the local z in the plane. Still thanks for the hints!
You would typically use the plane as a "floor" of some kind, so x and z makes much more sense as a default than x and y would.
Right right, I know. $$anonymous$$akes sense. But then I'm right that the choice of x,z is arbitrary in the sense that say, one of the definitions of plane is a fixed point in the basis and two orthonormal vectors. Could have been x,y too for that matter (as far as the definition, not taking into consideration the most likely use case of a plane in a 3d engine).