Unity Virtual Reality Projects
上QQ阅读APP看书,第一时间看更新

Adding a plane

Now, let's add a ground plane object into the scene.

In the Hierarchy panel, click on the Create menu (or main GameObject menu) and choose 3D Object | Plane.

A default white plane is added to the scene, centered on the ground plane at Position (0, 0, 0). (If necessary, select Reset from the Inspector panel's Transform component's gear icon). Rename it to GroundPlane.

Note that at a scale of (1, 1, 1), Unity's plane object actually measures 10 by 10 units in X and Z. In other words, the size of GroundPlane is 10 by 10 units and its transform's Scale is 1.

The cube is centered at Position (0, 0, 0), just like the ground plane. However, maybe it doesn't look like it to you. The Scene panel may show a Perspective projection that renders 3D scenes onto a 2D image. The Perspective distortion makes the cube not seem centered on the ground plane, but it is. Count the grid lines on either side of the cube. As you'll see, when it is viewed in VR and you're actually standing in the scene, it won't look distorted at all. This is shown in the following screenshot:

The cube is submerged in the ground plane because its local origin is at its geometric center—it measures 1 by 1 by 1 and its middle point is (0.5, 0.5, 0.5). This might sound obvious, but it is possible for the origin of a model to not be its geometric center (such as one of its corners). The Transform component's position is the world space location of the object's local origin. Let's move the cube as follows:

  1. Move the cube onto the surface of the ground plane—in the Inspector panel, set its Y position to 0.5: Position (0, 0.5, 0).
  2. Let's rotate the cube a bit around the y axis. Enter 20 into its rotation: Rotation (0, 0.5, 0).

Note the direction in which it rotates. That's 20 degrees clockwise. Using your left hand, give a thumbs-up gesture. See the direction your fingers are pointing? Unity uses a left-handed coordinate system. (There is no standard for the coordinate system handedness. Some software uses left-handedness, others use right-handedness).

Unity uses a left-handed coordinate system. And the y axis is up.