Game Development Reference
In-Depth Information
You can also set objects to snap at intervals and use a rotation snap.
1.
Select one of the cubes, and set its rotation values back to 0 .
2.
From the Edit menu, at the very bottom, select Snap Settings.
The grid snaps are set to 1 unit. This means that the object must be within 1 unit or meter of the grid
intersection before they will snap. Because the cubes' pivot points are at their centers, the cubes
were originally halfway down through the scene construction grid. The first thing to do is move it up.
3.
Select the cube again and, holding the Ctrl key (Windows) or the z
key (Mac), move the cube up until it snaps its base to the grid floor.
4.
Try snapping the cube to the grid in the Global X or Z direction.
Of interest is that the cube keeps the same offset, as it snaps 1 unit each direction. If you want it
to snap to corners, you can use the buttons at the bottom of the Snap Settings dialog to center
the cube on an intersection, add 0.5 to the X and Z in the Inspector, and then happily snap
between corners.
Angle or Rotational snaps are set to 15 degrees as a default. You will want to set them to some
number that makes sense for your needs before you snap rotate.
5.
Change the mode to Rotate.
6.
Hold the Ctrl (or Cmd) key down, and rotate the cube on its Y axis, noting the
15 degree increments or decrements in the Inspector.
7.
Feel free to round up if the rotation value in the Inspector is infinitesimally off
at the end of the rotation.
Parenting
So far, you have dealt with singular objects. It's quite typical, however, to group multiple objects
together and parent them to a single gameObject for easier handling. The most important thing to
know is that children inherit the transforms of their parents. If a parent is moved two meters in the
Z direction, the child is moved that same two meters. If the parent is rotated, the child is rotated
relative to the parent. If the parent is scaled, the child receives the same scale, again, relative to the
parent. It sounds straightforward, but it is worth looking into further.
1.
From the GameObject menu, Create Other, create a Capsule.
2.
In the Inspector, set its position to 0, 0, 0.
3.
Select Cube1, and position it at least a couple of meters away from the
capsule.
4.
Select the Capsule in the Hierarchy view, and drag and drop it onto Cube1 in
the Hierarchy view.
5.
Check its transforms in the Inspector, and make note of them.
 
Search WWH ::




Custom Search