Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Animation is what we use to bring life to a game. We've had a glimpse of it using physics to make art we can knock over, and now we're going to make components that are ready to animate. I want to look at the nature of prefabs and batching here in unity first and what that means, and how we should set up to animate a lot of objects. I'll go over to my game window. And, here in the game, I've turned on maximize on play and statistics. What this shows for us is the number of draw calls. The number of times, we're asking the graphics card to display something.
And then, the number saved by batching, or defining an object once. And then, referencing it again. When I hit play, we can see that draw call number change depending on where we're looking. If we're looking in a gallery and we can't really see out too many windows the draw calls are low. We're saving 61 or 59 by batching and then as we turn around we can see the draw calls shoot up because we're looking at more objects but we're batching a greater number. This means that there are more things that are defined once and then reused.
We'd like the art to follow this. Where we define a limited number of pieces, swap out the material and have it batch as much as possible. What I've done then is to bring in a selection of FPX files. Each one being one size of art. There's art painting rectangle large frame for example and rectangle large unframed. There's medium and then also medium odd size we'll call it, or medium tall, and even a small with 3 panels. These then correlate to the materials for those paintings.
I've gone through the materials folder in the meshes and made sure all the names work. We've got in here Art P, Art 4 Painting, and here's all the different paintings available. There's a few that have imported doubly and also a wood blackened which is the frame. We'll use the dark wood material on those frames and swap them in and out easily. This way we can define a frame size once and have three or four paintings that use it. I'll take the art piece circles for example, and tune up the material, and then get it on a frame. In the main color, I'll go into select, and I'll pick circles, color and shine.
This tells me it should be a BumpedSpecular shader. And then I'll go into the normal map and pick the Circles normal that matches. Now, I'll borrow that Specular color right from the painting, and just crank up the shine a little bit so it's got a little metalness to it. ArtP_Circles is ready. And I'll look at a table I created to tell me which art goes on which frame. This is a PDF included in the modernista design folder in the exercise files. This table shows the name of the piece of art and the frame size it goes on, along with the dimension and framed or unframed.
I've also included the word document, so if you'd like to add to this another column. Say maybe the building it's in or the wall it's on, you can add that in. It's very common to have lists of what the assets are and what kind of prefab they fit on. Especially as we get into many, many assets, keeping things straight requires some kind of list or table. I can see that circles goes on a rectangle large unframed. And so I'll put that material on that prefab. Back her in Unity, I've got my circles material ready. And I'll go into meshes and pick art > rectangle > large > unframed.
I'll drag into the scene and press F to focus in. I'll make sure I"m in the scene view. And there's that painting. If you notice here, I was in the game and it wouldn't let me drag it in. You can't pull things into the game view. This is where you view what's going on. Back here in the scene view, there's my painting, and I'm going to attach a box collider to it. It looks like this material came in as a transparent bump. So I'll make sure I get that on so we don't see through the painting. Here's my art piece circles, and finally.
Component. Physics. Box collider. Now this painting is ready to instant surround. I've made a prefab. And it's called Art P Rectangle Large Unframed. And so swapping in another material is easy. And it'll reference the same file over and over. I'll duplicate it. Slide the duplicate to the side. And get another painting on there. The next one I'll use is my desert. I'll pick the desert material .Make sure its a bunk specular shader and get the right maps in. Here's desert1993 color and shine and I'll get the normal map in as well.
I'll eye dropper the specular color and now I'm ready to put this on. I'll drag it right on and now that has switched, and I'll turn off the lightings so you can see it a little bit better. This is now using one prefab twice. And I'll get batching, or saving, of draw calls out of it. It's important to do this before we get into animation, because we are going to clone these objects all over. And any components that are on those objects will clone as well. So by putting the collider on once, I save myself that work making sure the art is on the walls and the walls are cloned as prefabs as well, will save me the work of dragging it in over and over, and in this case I can simply swap out the art, clone the wall and get it ready to animate.
Get unlimited access to all courses for just $25/month.Become a member
107 Video lessons · 33926 Viewers
94 Video lessons · 23700 Viewers
100 Video lessons · 4107 Viewers
78 Video lessons · 10300 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.