top of page

Blender to Unity and Playmaker | Part 2: Materials & animation

Video transcript :

Blender to Unity and Playmaker | Part 2: Materials & animation

Adding material

Lets add material to our object. Before moving on you need to understand that Unity does not recognize blender’s material other than its diffuse color. So you should tweak the materials in Unity later, not in Blender. What we need to do in Blender however, beside the diffuse color, is naming the materials and defining material slot assignment to the faces of our object. This is because Unity doesn’t have any capability to assign material per face, so again you need to do this in Blender before exporting it to Unity.

So lets go back to object mode first. Go to the material panel. Notice we already have the default material from blender called “material”. Lets rename this material to “metal_gold”. Usually Blender use dot, to separate words such as “”. But because when you export this to Unity and Unity actually store assets in files with different extensions based on the asset type. Unity like to use underscore to separate words instead of dots. So lets use underscore also in here, just so we have more consistent naming. You’ll understand how important it is when working on a project with a lot people and with a lot of assets. Okay. Lets change the diffuse color to gold like yellow color. Okay and now lets create a new material slot for the wood material. Click this new button in here. Rename the material to wood. The “W” letter should be upper case just like the metal gold on top. So we have consistency in our naming convention. Change the color to wood like brownish color. I think we need to reduce the saturation. Now lets go back to edit mode. Remember we still have these faces selected before. While they are selected like this, click the assign button in here. Now the wood material is assigned to the selected faces and we have the exterior shape of our treasure chest finished.

Finish up the 3D model

The finish up the model we need to split these edges in here so the upper part is separated from the bottom part. To do this we can go to edit mode again. Press Z to go wireframe mode. Go to edge mode and select these 4 edges. Then press alt E. Sorry. I mean control E. This will open the edge modeling functions. Then choose this “edge split” in here. Okay. Edge split will split the edges that we have selected before. Because of this, if we go to face mode for example and hover our mouse over any faces I here. Remember we’re just hovering the mouse now, not clicking on anything. Then press L key in the keyboard. Only the upper faces get selected. If we move this up. We can see that the object’s geometry get split up in the edges we have before. Okay now that we have these faces selected. We can actually make them separated to a new object. To do that we can press P, then choose selection. Now if we go back to the object mode. We can select them and move them independently as different object.

Now lets finish up the bottom part first. Select it and then press slash key on the numpad to localize it. So everything is hidden accept this object. Go to edit mode and then edge mode. Hold alt and right click on the border edge. Press F to fill it with face. Now go to face mode and then press I for inset. Notice Blender will use existing or previous inset value that we have before as the default. So just left click to confirm. Extrude this down. Go to side view by pressing 3 in the numpad. Then press Z to go to wireframe mode. Move the face down a bit. Then hit S to scale. Okay. Now we have the interior of the bottom chest. Press slash again to go out from the local mode. For the top or the cover part of the chest. The process will be identical so I’ll just speed up the video for now.

Now we have the interiors for both parts of the treasure chest finished.

Before we can create the animation. Notice if we select the upper part and then press R to rotate, then X to constrain the rotation to X axis. The rotation looks off because it uses the origin point as the center of the rotation and the origin of this object is at the bottom. To fix this. Go to edge mode. Then select this edge in here. Then use the quick origin add on to move the origin point to this position. Click this “set origin” button and now as we can see the origin point is in this location. So because we have corrected the origin if we rotate by pressing R then X. We can see the rotation looks correct now.

Currently if we import this model to Unity the object will have ugly generic names. So lets name these objects properly. Select the bottom one and rename it to “Body”. Then select the upper object again and rename it “Cover”.

Creating the animation

Okay next lets create the animation. If you are planning to create animation and render it right inside Blender you should have no problem with frame numbering. But because we’re going to export this to Unity. You need to understand several things regarding the animation import process. First of all, Any keyframe you put on zero frame in Blender will not get exported to Unity. Okay so you should always start your animation from frame 1, not zero. The second thing that you need to know is that frame number 1 in Blender will be named frame number 0 in Unity. So every keyframe numbering will be less 1 frame of the actual blender frame position. If you just remember these 2 things you should good to go -in sha Allah-.

To create keyframe for the animation we need a special editor called dope sheet. So click drag from this corner editor to create a new editor window. Change this to dope sheet. The timeline down here, we actually don’t really need it except for playback control and setting start and ending animation in here. So for now we can safely drag the dope sheet editor until it touches the timeline header like this.

Remember we need to start animating from frame one so place the playhead at frame one. Then make sure the cover object is selected. Then to insert a keyframe at the current frame, we can press I then choose rotation. By doing that Blender created a keyframe for the object’s rotation. Now, don’t get confused with all of these keyframes. We actually have one keyframe at the bottom. And the other three keyframes above it, are just the summary keyframes showing what is going on in their descendants. So basically if we create a keyframe in one object it will show up also on its hierarchical parents. Okay next after we have a rotational keyframe at frame one, lets move the playhead to frame 21. Remember in Unity later this number 21 will be number 20. So that is why we add 1 frame on purpose in Blender now. Go to 3d view and press R then X. Until the chest cover open like this. Okay after we have something like this, press I again to insert keyframe and choose rotation just like before.

Now move the playhead to frame 41. This will be frame 40 later in Unity. And then we need to create the same rotation keyframe for the chest cover just like the one we have in frame one. We can do this easily by right-clicking the keyframe at frame one. Press control C to copy it. Then press control V to paste it. And Blender will paste the copied keyframe from frame one to the current playhead location which is frame 41. So now if scrub the playhead. This is opening animation. And then followed by closing animation. Okay now press control S to save the file. I always turn on this “compress” option all the time to make the file size smaller. Lets name this file to “treasure_chest”. Hit enter and click the “save as blender file” button up here.

Okay guys that’s it for this part. In the next video we’ll cover how to import the 3d model along with its materials and animations from Blender to Unity and then add interaction with Playmaker plugin. As always don’t forget to subscribe to my channel. Give a thumbs-up if you like the video and give a thumbs-down if you don’t like the video. See you in the next part. Wassalamualaikum.

#unity #blender #tutorial #3Dmodeling #animation #playmaker

bottom of page