Starting Chapter Four

So far working through the new book Unity for Absolute beginners has been great. As I had said previously, the last book was riddled with errors but so far even though there were plenty of errors I had learned a lot and working with this new book has been great.

I also found a video created by Unity for animating anything using Mecanim. While I have found the videos published by Unity are severely lacking in specifics you can get where you need to go from the starting point they get leave you at. With that said, I should have the drawers on my dresser opening and closing using the Mecanim animation system as well as the legacy system. One piece of information the video left we with was that Mecanim is a state machine and having that knowledge leads me to believe this is the system I should be using for my game. Hopefully the next entry should have some videos with mecamin in action.

Back to the books

I was able to apply the animations and when I clicked play the worked! That was my goal for yesterday afternoon and things went so smoothly, much more so than I thought. I was finished within 10 minutes. I decided to take it a step further (remember, baby steps) and write a script to run the animation from the idle state and open a drawer when you press a key. The book I was referencing at the time had a very basic script to do just that and I modified it so you could open/close what ever drawer you wanted by pressing a key, 1-4 (drawers counting clockwise). As written the script did not seem to work without throwing any errors, syntax or otherwise. When I placed sections of the code into the update method rather than the start method like the author had it, it worked great. The amount of errors I see in some of these books out there is amazing. Who proofreads or edits them? These books run upwards of 3o.00!

Tonight I went back to the book ‘Unity for absolute beginners’, picking up where I had left off. The author is going to run through animation techniques using the Mecanim system in Unity vs the legacy system I used for the dresser drawers. When tried to open the project I could not find it anywhere on my hard drive. I think because the project was titled ‘Unity Test’ as per the book I deleted the folder in error. No worries, I caught myself up this evening to, just about to the point I was at prior to setting it aside for a bit.

Here is very brief glimpse of one of the drawers opening in Unity.

See ya Friday!

Animations

My goal this evening is to have my animations working when I press play. At this point I am taking this one step at a time. I have created the asset, my dresser. I have created the simple animation of the drawer opening. I actually created two animations without realizing it. I created one animation of the first drawer on the upper row opening slowly and another animation of the last drawer on the lower row opening fast. It appears the way the animations were imported I can use them on any part of the dresser including the dresser itself. I have imported everything into Unity, game objects, materials and textures. The animations work great in the preview window, now to add the game object to the scene and get the animation working when I press play.

Surprises are great

I have some level of comfort exporting from Blender and importing into Unity using FBX finally. I say some level of comfort because it works like a champ using material without nodes. Exporting/Importing with node materials is still a little sketchy. The first little surprise was the materials came over without any adjustment in Unity, meaning when I moved from Blender into Unity the textures were already applied to the materials. Every thing I have watched or read indicated I must drag and drop my textures onto the materials after import and I did not have to do that, it was automatic. The biggest surprise was when I created the animations in Blender. I was under the assumption when I created the animations in Blender the animation would transfer over as a single animation.What I am trying to say is, if I created an animation of two different drawers opening on my dresser, I would get a single animation with both drawers opening when the file was brought into Unity. To my surprise what transferred over was two individual animation files, one for each drawer, a hallelujah moment. Next on the list is apply the animations to the game objects and watch them move in Unity, first in the legacy animation system and then Mecanim, getting the node materials to transfer correctly can wait as I have my first asset created, imported into Unity with animations so it is time to get those to work first.

After I get both types of materials to export correctly and animations working in both animation systems I’ll put something together in print and possibly video showing everything I needed to do. I hope this would help others that have had specific questions along these lines and found it as difficult as I have to get that information in one place.

Blender to Unity #1

I made my first attempt at transferring a model from Blender into Unity and ran into one hiccup, the materials did not transfer over. The model looks good but when I select either the drawer or dresser in Unity the inspector shows the same material, ‘No Name’ shader. The problem here is both items have the same material which means when I place the texture into the shader the both get the same texture and they are two different textures. I made an error in the naming of the textures in Blender or did not select a check box or…. I’ll figure it out and update. I’m sure it is something simple.

Edit:

Here is the results of the first import after reverting to regular non-cycles materials. I created and then baked the materials/textures in cycles but had some problems exporting. It was exporting textures that were not attached to any materials. I tried removing all fake users etc., saving and loading again yet, one texture image remained. Now I know why people always ask for a way to view and or delete orphaned textures. So, this is the first iteration, no animations though, baby steps 🙂

Dresser_UT_01

Game Asset Complete

My first game asset is complete for testing purposes. Tonight and during the weekend I will be create animations foe each of the drawers with sound of them opening and closing. After this I will be importing everything into Unity and creating scripts to open and closed the drawers. I’m sure this will be just the first of hundreds of test and retests I will be doing during the creation of this game.

Yesterday, I found a book I think I have been looking for. It is called: ‘Practical Game Development with Unity and Blender’, the perfect companion book for what I am trying to do. This book was just released in June 2014 (this year) using Blender 2.68a while I am using 2.71 and while I am not sure of the version of Unity he is using, given the time frame of release I’m betting he is using 4.3 while I have 4.5 (I skipped 4.4 or it was console only, not free).  With that said this book looks to be the ticket as it will not be running through all the basics of Unity or Blender interface, which I am very familiar with and, crossing fingers here, getting into some of the things I have been looking for information on. I would much rather find all the information I need myself through searching online, videos or reading books. The last think I want to do is ask on the forums. I am not against asking there, I don’t want my questions to end up being very easy to answer if I had only looked. If I get completely stuck, yes I will ask but only as a last resort.

Here is my finished product: Dresser

LivingRoomDrawers_08

LivingRoomDrawers_Open_08

Dresser close to complete

I am just about complete with the dresser game asset. I created the drawer face and handle, found some textures and set about trying to figure out how to add everything together (parent or join). Quickly creating a new version of the blend file to test, test and retest I eventually came up with a process that seems to work. I joined the face and handle to the interior box of the drawer creating one object, UV unwrapped the entire drawer using smart UV project and working with the settings came up with a workable unwrap. I then created three different materials/textures, one each for the face, interior box and handle then selecting the appropriate polys, assigned the correct material. I’m not really sure if I should have done this with vertex groups or not, I am just relaying here (for later recall) what worked.

Now to bake the textures. I tried baking each texture individually which worked however I could not get all the materials into one image texture unless of course I saved each separately brought them into Photoshop as individual layers and merged them together. I then had an epiphany, in all the tutorials, which have been short and quick showing how to bake textures in Blender using cycles they only baked one material at any one time. I then decided to try to add the image texture node used for baking to each of the materials for the drawer, referencing the same UV map in each. I selected the drawer and then bake. After a couple minutes wait (I had the samples set a little high) I had the results I was looking for. All three textures, drawer interior box, face and handle baked onto the same image.

The image below is s screen shot of my finished bake, following that is the ‘close to complete’ dresser. I have to duplicate and place the drawers which are currently diffuse textured place holders. I will then call this one complete for testing purposes anyway. I will also try instancing the drawers rather than duplicate to see how that will work in Unity as well.

Multi_UV_Bake

LivingRoomDrawers_07

Cycles Baking

I started baking my game assets using cycles today and I think it turned out pretty good take a look at the results below. What I’m not sure about is when I add the faces of the drawers and the drawer handles will I be parenting these to the existing drawers or adding them to the drawer model and then creating a texture sheet with all of the textures included.

LivingRoomDrawers_06

BI (Blender Internal)

I have been back on the computer working in Blender, started adding textures to my game assets when I realized how long it has been since I used the Blender Internal render engine. I am not sure if using BI is the correct or only direction when creating and texturing assets for a game, I am going to be using Unity3D and Unreal Engine 4 for the game engines. I am actively searching for materials regardless of the media (Books, articles or videos) on the subject of creating assets for a game engine. I am sure they are out there but I have found the topic of creating assets difficult to find. Most of the information I have located concentrate on the programming aspect and don’t pick up on the modeling aspect. Actually I am comfortable with the modeling just not the baking/texturing when it comes to game assets.

I ran across a tutorial set in work a few weeks back which creates a horror game from start to finish. He uses 3ds Max for the modeling where I use Blender but as with most software I am familiar with, if you know the concepts you can use whatever tool you are familiar with. This course is very detailed with the last part produced at two hours and there is no telling how long it actually took to create not to mention edit.

I also found some items on CG Cookie/Unity that might be of some help as well as a book titled “Game Development with blender”. I am not interested in using Blender for the game engine however any modeling mentioned should be relevant for my purposes.