Working with Models, Materials, and Textures in Unity Game Development
The Basics of Models
Video games wouldn’t be very video without the graphical components. In 2D games, the graphics consist of flat images called sprites. All you needed to do was change the x and y positions of these sprites and flip several of them in sequence and the viewer’s eye was fooled into believing that it saw true motion and animation. In 3D games, however, things aren’t so simple. In worlds with a third axis, objects need to have volume to fool the eye. Because games use a large number of objects, the need to process things quickly was very important. Enter the mesh. A mesh, at its most simple, is a series of interconnected triangles. These triangles build off of each other in strips to form basic to very complex objects. These strips provide the 3D definitions of a model and can be processed very quickly. Don’t worry, though; Unity handles all of this for you so that you don’t have to manage it yourself. Later in this hour, you’ll see just how triangles can make up various shapes in the Unity Scene view.
Built-In 3D Objects
Unity comes with a few basic built-in meshes (or primitives) for you work with. These tend to be simple shapes that serve simple utilities or can be combined to make more-complex objects. Figure 3.1 shows the available built-in meshes. (You worked with the cube and sphere in the previous hours.)
FIGURE 3.1 The built-in meshes in Unity.
Having built-in models is nice, but most of the time, your games will require art assets that are a little more complex. Thankfully, Unity makes it rather easy to bring your own 3D models into your projects. Just placing the file containing the 3D model in your Assets folder is enough to bring it into the project. From there, dragging it into the scene or hierarchy builds a game object around it. Natively, Unity supports .fbx, .dae, .3ds, .dxf, and .obj files. This enables you to work with just about any 3D modeling tool.
Models and the Asset Store
You don’t have to be an expert modeler to make games with Unity. The Asset Store provides a simple and effective way to find premade models and import them into your project. Generally speaking, models on the Asset Store are either free or paid and come alone or in a collection of similar models. Some of the models come with their own textures, and some of them are simply the mesh data.