Blender: Making a tank, all one piece or break it up?

I am learning to model in Blender, I am going to start making the easiest possible tank, a square turret, with octagon-al treads and a square hull with a square gun. Should I make the tank as one complete object, or import it into unity as separate parts?

1876198--120614--tank.png

Like you have to have a script to rotate the turret, so wouldn’t it be easier to rotate the turret if it was a separate object?

And how to make tank treads “move”? I intend to apply a texture to the treads that makes it look like they are going forward/backward, but it is just an octagon in reality. How would you script this in C#?

Break al the pieces that need to be able to move individually. You can keep them in the same file as long as you separate the meshes.
In your case I would say individual pieces should be: chains, hull, turret and barrel.
You can make the chains animate by giving them a scrolling texture (which need a special shader you need to make yourself or google for it). Also make sure to set the pivot of each object to a logical location - meaning: the point around which the thing will rotate. Finally you should probably arrange them hierarchically:
hull (parent)
chains and turret (children of hull)
barrel (child of turret).

Ok. I have made them parents of each other as you have said.

In which program would I set the pivot point of the turret in? Would I do that in Unity or Blender?

And also my tracks, gun, and turret look oddly darker than the hull…

Blender. Unity can’t change pivots. You can fake it by using intermediate empty objects but if you can do it inside the object natively always do it inside the object. Introducing extra objects into the hierarchy just for pivot placement can get problematic down the road, is unnecessary except in special cases and bad style. :slight_smile:

You can have it in one piece if you want, by rigging it and using a skinned mesh. However that requires learning about rigging and weight painting, so it would be easier to use multiple pieces. On the other hand, that’s a pretty good way to start learning about rigging, since it’s less complex than a character.

–Eric

1 Like

well now I just have to learn unity. I have successfully imported my asset into the program, with pivot points set. Ok. I click the hull and it shows me all the verts, I click the turret and it shows me the ones in the gun and turret. Maybe now I just add a script?

Idk how to do add a script, I assume you have to do some kind of: if key pressed, rotate turret by something and include “time.deltatime” ; Is there a page to learn how to code rotations?

And then I need to set the gun as some kind of physics material and make it a hinge on my turret, which is a hinge of my hull? And can I have both a box collider and a joint? Whats the difference between hinge vs spring?

I guess I’m just asking about where do I learn this stuff?

www.Unity3d.com/learn

Rigid animation and skinned animation are two different things. Skinned animation would typically be animations recorded in Blender (or some other program). It involves skinning (attaching vertices to an armature - which requires that there be an armature) and rigging (which is setting up your armature to make it easy to animate with).

Skinned animation is great for creatures and humans where you need the texture to kind of bend around the surface and where an artist is going to do animations in Blender (or some other program) that will be played back in the game.

Rigid animation is what you’re doing. In rigid animation, every “piece” is created as a completely separate mesh in Blender (or some other program), and then the pieces are “parented” to one another in a family tree of relationships. This can go several levels deep with great-great-great-grand-parents and such. Each mesh has its own transform (world matrix) and because of that they can be positioned or oriented independently of one another. Because of the parent-child relationship, they can also move and orient as one piece.

The way that it works is that when you move or rotate the parent, the child goes with it. Yet when you move or rotate the child, the parent is unaffected. This allows, for example, the wheels of a car to rotate separately from the car yet when the car moves forward the wheels stay attached.

In code, this is accomplished by the fact that both the car and the wheels all have separate world matrices (transforms in Unity). When the model is imported, these relationships are noted by the software. Then the transforms(or matrices) are applied from parent to child. When you multiply the parent’s world matrix times the child’s world matrix, the result will be a world matrix that places the child in the scene relative to the parent both in terms of position and orientation(rotation).

As far as pivot points, the pivot point is always the origin (center of the 3D universe). If you look at the math, there’s no other possibility. So, your vertices are where you put them in Blender, mathematically. When you import the model, they’re still where you put them. By applying the object’s transform(world matrix) to the vertices you move those vertices and rotate them. So, if the transform (world matrix) is set to an identity matrix (probably zero’ed out in Unity) the vertices will be in their natural place they were originally created in.

When you rotate, the rotation happens around the origin. If the object is centered at the origin, this causes the object to rotate. If the object is not, it will basically orbit the origin because its still rotating around the origin. So, as you probably know, the trick is to move the object to the origin between draw frames, rotate it, then move it back.

In a parent-child relationship like this, the child’s “origin” is the parent’s transform (world matrix). Because the child’s transform (world matrix) is combined (by multiplying) with its ancestors, it will be positioned and oriented relative to them. If you did not do this combining (multiplying), the object would be placed and oriented relative to the origin. Unity typically handles most of this under the hood with its parent child relationships and transforms.

Of course, when you go to rotate a child, you still have to move it to the origin between frames or it will orbit its parent rather than rotating around its own axis.

Unity typically does this by making a game object a child of another object.

Note that in rigid animation you don’t animate in Blender, you don’t skin or rig, in fact you have no “armature”, and you have separate meshes for each part. In skinned animation you have the opposite and may only have one mesh. The vertices of the single mesh are probably attached to the bones of the armature which in reality each bone is a world matrix (transform). Theoretically you could animate a skinned model through code, but you usually don’t. Theoretically you could animate a rigid model in Blender, but you usually animate it in code.

1 Like

No, you can skin and rig a rigid animation. I’ve done this; it means you have a single renderer, and one draw call (if there’s one material). This isn’t important for just one object, but if you have many (as in an RTS), it adds up. The bones are transforms which you can manipulate in Unity as usual.

It’s quite common, such as making a character’s head look in a particular direction, aiming weapons, etc.

–Eric

Both are valid ways to do this, actually. What suits you better is based upon the project and preferences of the team/programmer/animator. I am not sure how much the performance differs between the two things on a simple model like a tank, actually. Would be interesting to make a few tests. Different model parts at least should result in more draw calls as the objects aren’t static.

In the end I know that for a project I worked on we split the tanks the way I described earlier because we wanted to change parts on the tanks (even though this can be achieved by rigging as well - though it makes less sense in that case). For the original question I’d recommend sticking to the split model setup as OP is a beginner and a split model is easier to handle and change, IMO. The parts are directly visible and changeable in Unity and changes on the model don’t result in changes on the rig setup.

Though - yes. Both are viable ways despite that rigging probably isn’t the first thing one might have in mind for mechanical objects like a tank. :slight_smile:

(edit)

Sorry but that is not true at all, BTW. For a tank it makes sense to set all the rotations by code but object animation may very well be animated in the 3D package. Just because something doesn’t have bones and vertex weights does not mean that it’s only animated by code.

You should draw it on paper first, and use that as a referance when modeling inside of Blender so you always have a good feel of what you are making, then mold your model to it.

http://www.the-blueprints.com/blueprints/tanks/

Enjoy! :sunglasses: