Manipulating models in 3D space in Unity

At this point, you have the arena set up, but it’s missing the guest of honor! You need the space marine for your game. There is a problem. The space marine was shipped in two different pieces. There is a head and a body. Some assembly is required.

Adding the two models to the Scene view isn’t enough. You need to be able to manipulate them in 3D space. Thankfully, Unity comes with a few tools to help you out.

Note: This tutorial is part of a collection that teaches Unity development from the ground up. You can read the entire series over here. This series is free and does not require any account creation. All assets are provided. If you find it useful, feel free to buy me a coffee.

Adding the space marine

To get started, you’ll add the body first. With your Unity project open, open the Models folder then drag BobbleMarine-Body into the Hierarchy.

This shows the marine body being dragged to the Scene view.

This time you are dropping the model directly onto the Hierachy versus dragging to the Scene view. The result is almost same except for the starting position.

Remember, Unity games are organized by scenes. You can think of a scene as a level of your game. The Hierarchy view is a list of all objects that are being used in the current scene. You’ll notice that the Hierarchy contains several other objects: Main Camera, Directional Light, Global Volume and the Bobble Arena.

You may also see something like this:

This shows the Scene view above the Game view. The Scene view shows the arena where the Game view shows the marine.

The top view is your Scene view, but the bottom view is your Game view. You are seeing the game world from the position of the Main Camera. You’ll be interacting the Game view soon enough.

Click on the BobbleMarine-Body in the Hierarchy. Next, hover the mouse over the Scene view and press the F key to zoom to the marine. This shortcut is useful when you have many objects in your scene and you need to quickly get to one of them.

A dark headless is placed underneath the arena.

You’ll also notice the marine is a little dark. This is because the arena is blocking the light source, casting a shadow on the marine. Select the BobbleArena in the Hierarchy. In the Inspector, you’ll see checkbox next to the BobbleArena name. Uncheck it.

This disables the model from the current scene, but still keeps it in the Hierarchy. You’ll now be able to properly see the marine.

The marine is shown again, this time properly illuminated.

Notice that the model is now greyed out in the Hierarchy:

This shows a greyed out BobbleArena in the Hierachy.

It’s often useful to disable objects during development and even during gameplay.

Learning the Scene tools

While the space marine’s dismembered body is pretty intimidating, they are going to have a hard time shooting alien monsters without a head!

Drag the BobbleMarine-Head from the Project window into the Hierarchy. Chances are, the head will not go exactly where you’d hope.

This shows the marine's head colliding with the marines body.

Select the head in the Hierarchy to see its navigation gizmos. By selecting and dragging the colored arrows, you can move the head in various directions.

This show the transform tools on the helmet.

By clicking and dragging on the green arrow means you’ll move the head just on the y axis. The red arrow represents the x axis and the blue arrow is the z axis.

The colored faces of the cube in the middle of the head allow you to move the object along two axes at the same time. For example, selecting and dragging the red face — the x-axis — allows you to move the head along the y- and z-axes.

You can also use the Scene view toolbar to make other adjustments to an object.

This shows the Scene view toolabr.

You use this toolbar to manipulate the positions of your objects in 3D space. Here’s the breakdown.

This is the hand tool icon which is a hand.

The first item is the hand tool. This allows you to pan the Scene and is equivalent to holding down the middle mouse button. If you hold down the alt key (option on macOS), you’ll be able to orbit the selected object. If you right click and hold alt, you can zoom by dragging the mouse up or down.

This is the move tool which is four arrows.

The move tool allows you to move an object using the axis arrows. The w key is the shortcut key to activate this mode.

This is the rotate tool which is two arrows arranged in a circle

The rotate tool allows you to rotate an object along various axis. Click and hold on an axis and then drag the mouse to rotate it. The e key is the shortcut key to activate this mode.

This is the scale tool which an arrow point up to the right.

The scale tool allows you to enlarge or shrink an object. You can scale on object just on a single axis, or affect the entire thing. The r key is the shortcut key to activate this mode.

This is the rect tool which is four dots in a square with lines between them.

The rect tool lets you rotate, scale and reposition sprites. You’ll use this when working with the user interface and Unity 2D. The t key is the shortcut key to activate this mode.

This is the transform tool that has a cross in a circle.

The transform tool combines the move, rotate, and scale tool into one Swiss army knife. The y key is the shortcut key to activate this mode.

As you can see, you have lots a tools at your disposal.

Positioning the head

Using the aforementioned tools, tweak the position of the helmet so that it sits on the hero’s neck. It doesn’t need to be perfect. Just try moving the head to get used to the tools. When complete it should look like the following:

This shows the assembled space marine.

Now your marine is ready to rock!

Before moving on, enable your BobbleArena. To do this, select the BobbleArena in the Hierarchy, and in the Inspector, click the checkbox next to the BobbleArena name.

Where to go from here?

Congratulations! You now have a space marine at the ready to kill all the alien monsters, and you’ve learned a lot about the Unity user interface and importing assets along the way. You’ve also just completed the first chapter! Feel free to download the completed Chapter 1 sample project here:

https://drive.google.com/file/d/1JkwomUuaGZ75qDjfMW0cxHmTmhFDCJFt/view?usp=sharing

In this chapter you’ve learned:

  • How to configure the Unity layout, including customizing it for specific tasks.
  • How to import assets and organize them within Unity.
  • How to add assets to a scene and position them manually.

In the next chapter, Chapter 2, “GameObjects,” the aliens will finally catch up with the space marine — and you’ll learn about GameObjects and Prefabs along the way!


Discover more from Jezner Blog

Subscribe to get the latest posts sent to your email.

By Brian Moakley

Brian Moakley is a writer and editor who lives amongst the quiet hills in New England. When not reading tales of high adventure, he is often telling such stories to all who will listen.

Related Post

Leave a Reply