Unity Quick Tip - Placing Objects on the Ground

Unity Quick Tip Placing Objects on the Ground

More often than not, when we're placing objects in our scene we want to place them on the ground. This can be tricky to get exactly right when positioning manually, so in this quick tip we'll look at a feature of Unity that does this for us automatically.

To demonstrate this, we'll create a new 3D Project.

Creating a new 3D Project

We'll add a Plane to the scene by clicking the plus button on the Hierarchy panel and selecting 3D Object->Plane.

Adding a plane to the scene

Next we'll add a cube to the scene by clicking the plus button on the Hierarchy panel and selecting 3D Object->Cube.

Adding a cube to the scene

When the cube is added to the Scene it is buried in the plane rather than sitting on top of it. 

Cube buried in the plane

We could try to drag it up so that it is sitting on top, but this is hard to get right with the naked eye. Instead, we'll hold down Ctrl and Shift, or Command and Shift on a Mac.

We can now drag the cube around and it will automatically snap to the surface of the plane and we can position it where we want.

Dragging the cube on top of the plane

If we now add another cube to the scene and hold Ctrl and Shift again, we can see how it snaps to the plane and to the original cube, so we can easily stack items on top of each other.

Cubes stacked on top of each other

That covers everything for this tip. We hope that you found it useful. Please leave any questions or feedback in the comments below, and don't forget to subscribe to get notified when we publish our next post.

Thanks.

Comments

Popular posts from this blog

Rotating a Character in the Direction of Movement - Unity Game Development Tutorial

Changing the Colour of a Material - Unity Game Development Tutorial

Creating Terrain from Heightmaps - Unity Game Development Tutorial