Lets Make A Multiplayer Tank Game – Part 2.5 (Making a tank)

Before we get into spawning and movement, we need a tank for the player to spawn and move in. I thought about a few ways to do this – the easiest would be to just have an empty game object with some basic cubes to represent the tank. That sounds kind of lame though. You are free to create your tank however you want as long as you have a body, and turret that is separate from the body. However, for those who want to make something a little more cool, follow along as I walk you through creating a simple low poly tank in Blender.

ASIDE: “Blender???” I hear you say. Yes, Blender. It’s free, the learning curve (in my experience) isn’t super steep (for basic things), since 2.8 has been a lot easier to use, and perhaps most importantly learning the basics of Blender will allow you to prototype things you previously could not, and allow you to rely on pre-built assets less. If you would like to skip this section, I have included the final .fbx file for the tank I am creating in this post so you can follow along going forward if you either don’t care about making your own or if you already have your own tank.

ASIDE: There may be future .5 style lectures, they will typically focus on other things that are related to the project but not focused on netcode specifically.

Ok so, I am going to show you how to make a low poly tank in blender, import it into Unity, and set it up as a prefab.

First, here is a crash course in Blender. If after following along you want to learn more, I highly suggest Grant Abbits content, the CG Fast Track sword tutorial, and everyone’s favorite donut (Seriously, that donut tutorial is gold)

Course, Crash.

Head over to the official blender website and download yourself a copy. Install it. Easy. Now open it up (I wish other things loaded this fast *cough* Unity *cough*).

When you open it, you will be greeted with the following scene:

This might seem overwhelming, but you can ignore most of what you see for the time being. Here are the important bits:

This functions like the hierarchy in Unity does. You can parent objects, rename things, put them in collections, etc. For now, just leave it be.
For this, and for many things, the *only* thing you care about on that bar is the selection box tool at the top. Just pretend the rest don’t exist.

Blender has several modes you can switch between. The two we will be using mostly are Object and Edit. You can think of these like the scene view vs clicking into a prefab to make edits. In Object Mode you can select objects, add new objects, etc.

You can add new objects to your scene in two main ways – either through the “Add” menu you see:

(For now, ignore everything that isn’t a basic mesh). Or by pressing Shift + A. Blender *loooves* it’s shortcuts and honestly, it’s worth learning them. You can pretty safely follow the 80/20 rule here – 20% of shortcuts will take care of 80% of the things you want to do. I will cover the ones I think are crucial as we go.
This area has a bunch of stuff, most of which you can (again) ignore for now. The current tab should be on that orange square and shows you information about the objects (the cube in this case) transform – this is very similar to the Transform component on any GameObject in Unity.

I mentioned two modes, object and edit. You can enter edit mode by selecting in object and hitting the tab key – when you do the bar on the left should change and it will look like:

That looks like a lot, but all we really need for this is:
And honestly, most of what you will do in edit mode is typically done with keyboard shortcuts. However, if you find that going forward you are *really* uncomfortable with those you can use the buttons shown to achieve the same thing. Hovering any button in Blender will tell you what it does, and if there is a shortcut, what that is:

I am going to assume you are in edit mode with the cube highlighted. Lets cover some basics:

See those three icons at the top next to the words “edit mode”? Great. The first lets you mess with individual points (vertices) on your object. The second does the same, but for edges, and the third lets you select entire sides or “faces”:

You can select multiple vertices/edges/faces by shift clicking like in most applications. Which you use depends on what you want to do, but they are how you can poke, prod, squish, and move parts of your object. Mess up? Control Z. You will probably mess up. The shortcuts for these three selection methods are 1, 2, and 3 on your keyboard. If you don’t see the translation arrows, click the first of:

Those will give you widgets for translation, rotation, scale, and.. a super gizmo that does it all. This is pretty close to what you see in Unity:

One of the hardest things when learning something new is being able to relate it to what you already know. Wherever possible I will make a comparison I think will help 🙂

Ok, I am going to rocket through a few more commands and other you should know, and then we can start making the tank:

  • A – Select All:
  • Alt + A – Deselect all
  • G – Grab (move your mouse around to move the object in the scene). Left click to place.
  • S – Scale (move your move up and down to scale either an entire object or a selection):
  • R – Rotate (move your mouse left/right to rotate):

You might have noticed we are on a grid, similar to the one in any Unity scene. Lets say you want to move the object on the green (y) axis. You *could* click the icon and drag it by hand – or you could hit G + Y (Grab on the Y axis):

You can see it stays on that axis. This might seem basic but it is an extremely powerful concept for Blender allowing you to make complex edits pretty darn easy. Play around a little. The other commands (S)cale and (R)otate can also be modified by selecting an axis after the first command. S + X for example (scale on X) gives you:
Anyways. Play around. Break things. Hit control Z. Really screw things up? Just make a new scene.

Moving the Camera:

  • Middle mouse lets you rotate around your scene.
  • Shift + Middle Mouse lets you pan.
  • Scroll zooms.

The last two things I need to cover are extruding and insetting. If you thought the shortcut for those were E and I, you could be right. Extruding extends parts of your object, etc. Insetting lets you adjust the size of the area to be extruded:

There, I selected a face on the cube and hit E followed by G and X (Extrude, grab, move on the X axis). You can see that the extruded part can then be manipulated (in this case but using the g and z keys).

Insetting looks like this:

I selected the face from the previous extrusion and hit “I”. You can then move the mouse to adjust this. Sometimes blender only will let you inset so far using this method, so if you need it to be smaller and Blender is fighting with you, scaling the inset after making it will work:

Finally, I extrude again from that new face:

I am sure you can see how powerful combining grab, scale, rotate, axis locking, extruding, and insetting can be. This is a great way to make some super simple prototype art that gets the point across. One other thing you should know about extruding – if I select opposite sides of the cube and hit E, this is what happens:

But that is probably not what you want. Instead, you need to click and hold on the icon shown:

and select “Extrude Along Normals” – then click the little yellow “handle” and when you drag it you will get:

Here is something I made quickly, using only what I have shown and starting with a cube:

Now *this* is art. I kid, but I hope you can see that making basic objects for your own projects is not as hard as you might think. There are of course other tools – turning on wireframe mode for example:
Lets you see through the object and select things on the other side. Without that, if I drag selected my box, the sides I can’t see wouldn’t get detected. With wireframe, you know you have selected all of the faces:

Ok. Now that you are an expert 3D modeler, lets make a tank.

Making A Tank

I am going to walk you through how I made the tank with as much detail as possible. Don’t worry if yours is a little different – remember as long as you have a body and a turret it should work. It is very likely at some point you will accident hit a key toggling some setting that changes things and you won’t know what you did. Don’t sweat it. Control Z. Worse case, start over. It’s not the end of the world.

  1. Start with a new scene and the basic cube. There is a joke in the Blender community:
Blender Default Cube "Am i Joke to You?": blender
Since we are starting with a cube *anyways* feel free to keep the one in the scene, although deleting and adding it is a good thing to practice:

Select the cube by clicking on it, then hit tab to enter edit more. Select the top face (hit 3 on your keyboard or click the icon):

Hitting G and then Z will allow you to flatten your box some (since tanks are not cubes):

Remember you can always use the editing widgets, but I will be sticking to shortcuts.

Hit middle mouse to rotate around your object. Select one of the sides along the green axis (y) and hit G + Y to extend that side:

This is a great time to bring up something that you need to know how to fix and won’t know how to do so (at least, if all you have followed is this post) – you see that little yellow dot? That is the pivot point. If I hit tab to go back to object mode (which you will do before you export) and then if I was to select all (A), hit R to rotate and X to rotate on the red axis, this is what happens:
You might have expected this. Either way, the pivot no longer reflects the center of the object. When you export your modal to Unity, the pivot goes with it. Keep that in mind. To fix this you need to:
Followed by:
The first action, apply all transforms, will make sure that any scale you might have messed up in edit mode is reset to 1. If your object has incorrect scaling, all sorts of nasty things can happen when you make edits. The second action will move the pivot back to the center:
Anyways….

You might have also notice that crosshair looking thingy. That can be adjusted by Shift + Right Click. That is the 3D cursor. New objects you add you your scene will be created at that point. To reset it to the center of your scene:

Hit Shift + S, this will bring up:

Select “Cursor to world origin” but take note of the other options for future edits. Lastly, I want to recenter my “tank” – there are a bunch of ways to do this, but I am going to (in object mode) select my cube, hit Shift + S again, and select Selection to Cursor:
Final result:

Another way is to hit “N” or click on the little arrow:

This will open the transform panel:
and you can just reset your X, Y, and Z location values to get the same effect.

Ok, back to edit mode. I want to go with a low poly sci-fi style tank, so to make the shape a little more.. tank like, I am going to hit 2 to select edge mode, click one of the top edges, and then shift click the other:

When selecting multiple vertices, sides, or faces the last selection will be in white. This is important for certain things you will encounter later in your Blender adventures.

Next, Hit S for scale followed by X:

Then G (grab) + Z:

You could also have hit 3 (face select) and selected the top, which would have done the same thing.

Next, since we want the tank to have seperate parts, go back to object mode with tab, and hit Shift + A to bring up the Add menu and then select mesh->cube:

Amazing.

This is going to be the upper body of our tank, and our turret will be attached. If you wanted, you could make modular tanks by creating several version of each part and then combining them in Unity (swapping barrels for example) – I am going to keep it simple though. Select the new cube and go back to edit mode – hit G + Z to move it up a little:

and then using what you have learned, try to get something like:

It doesn’t have to touch, and infact will be exported as a separate object so don’t worry about making it perfect. Next we will use the inset and extrude features to make it more… turret like:

(I also scaled the sides to make it less boxy)
After you get that, hit S for scale and X for the axis, and make it more… turret shaped:
Then, hit E and pull it out:
And there you have a basic tank. If you tab back to object mode, you can hit R to rotate around Z and you can see it moves like we might expect:
Great, we now have a tank base, and a tank turret. Next we need to get them into our project. Honestly, feel free to start over and make your own tank. With the tools I have shown you can make something a bit cooler I am sure. This brings me to the last Blender technique you really need to know for basic modeling – edge loops. That word sounds scarier then it is. An edge loop just allow you to add edges. In a loop. It’s probably easier to show it.. Hit control + R with your upper tank selected in edit mode and hover over the barrel:
Click to place it. This basically has the same effect as if you had a shorter barrel, and then extruded the second part. But more importantly, instead of having 4 sides, now we have four sides made of two pieces each:

Now you can work on the new part without worrying about the other part. However, that loop was right in the middle. When you create a loop, click once, and then you can slide it on your object:

Now, you can do something like:

by using inset and extrude to add detail. Knock yourself out. I highly suggest again watching the tutorials I linked – if you follow even just the first Grant Abbit one you will be able to make a tank 5x as cool.

Exporting to Unity

Great, we have a tank. Now we need to get it exported out of Blender and into our project. First, lets give our objects names – you can double click the “cubes” in the collection to rename:

Make sure you DELETE the light and camera or you will be in for a surprise when you import…

To export, you goto file -> export -> fbx:

However if we do that as is, we will get the entire tank as one object. To get both parts out, select each first before exporting. The last thing we need to do is fix our normals. Without getting into it, if we import this mesh half of the faces will be rendered from the wrong side. If you want to know more, this post explains the reason a lot better then I can.

TLDR: Select your mesh (top or bottom), go into edit mode (tab), and hit “Shift + N”. Do that for the top and the bottom parts of the tank.

When you open the export window check the box “Selected Objects”:

Name the file and save it somewhere on your machine:

Then, you should be able to drag them into your project like any other asset:

Again, if you import these and something is “Very Wrong” â„¢ make sure you fix your normals. I am not 100% sure where in the process this issue occurred, but it did, and that’s how you resolve it. You can grab the complete, already fixed tank here – just unzip and drag the fbx files into your project:

Leave a Reply