Beginning 3D Game Development with Unity 4

Hi all,

My name is Sue Blackman and the second edition of my book is finally out! As you may have guessed, the title is Beginning 3D Game Development with Unity 4 (Apress, publishers). As with the first edition, I’ve written this book especially for artists and designers and those of you who are new to scripting and game development in general.

The book is project based and takes you through the process of creating a first person adventure game- a genre that is very forgiving and well suited to beginning scripting. Even if adventure games aren’t your final goal, you will be able to get a handle on the concepts and implementation of game logic, state management, inventory, saving/loading and other in-depth topics useful in many other types of games. The approach is to start small and add functionality a little bit time with plenty of visual feedback for your scripting efforts.

While the first book’s project was a classic adventure game, this time around, I’ve included physics and some favorite Unity special effects as part of the interaction. With Mecanim as the foundation, the introduction of a couple of NPCs (non-player characters) and the creation of a dialog tree helps make this version more contemporary.

For those of you new to Unity, you will soon discover that Unity tends to make changes in each release that can make authoring for this great game engine, well, challenging. Bookmark this first post- I’ll be adding errata, clarification, and later, changes required by new Unity releases.

I hope this book will help many of you take the next step toward that ‘dream game’ you’ve always wanted to make!

-Sue

Errata:

Page 111, steps 9-11 talk about adding a tree, “Big Tree” to the scene. In the first edition, I had people build a tree, so had them bring that package in when they first set up the project.Big Tree is included with TreeCreator.UnityPackage. It can be brought into an existing scene with Assets (the menu)>Import Assets> Tree Creator or right-click in the Project view)>Import Assets> Tree Creator

Page 113, step 1 instructs you to “Locate the Palm tree in the Project view and drag it into the Scene view”.
should probably read: step 1 “Locate the Palm tree asset (blue box with paper icon), not the Palm folder, in the Project view, and drag it into the Scene view”.
If you are using Two Columns Layout, the Palm image will have an open arrow on its right side

Page 117, step 10 refers to selecting “Refresh Tree and Detail Prototypes” from the Terrain menu. Unity removed the Terrain menu and spread the functionality throughout the Inspector. There is now a Refresh button next to the Edit Tree [ or Edit Details] button for trees and detail meshes, so if you change an asset (I think we adjust the Scale Factor for the Old Banyan Tree), it must be “refreshed” for the changes to be updated in the terrain.

Pagec 147 156, Appendix B was a list of the strings names of keyboard keys, Input.GetKey (“a”)
A short version can now be found by searching “Input” in the Manual

Page 473, There is no resetMO variable, do not add the following 2 lines (it was left over from some de-bug test):
//reset mouseover s
if (resetMO) GUI.Box(Rect(0,0, Screen.width, Screen.height), “”, customGUIStyle);
For those of you who are interested, the Box control blocks mouseovers on the 3D objects behind it. This “empty” box was set to full screen size.

I re-downloaded the assets but both zip programs I have still say there is an error. I sent a email to Apress support.

They replied and said there is no problem. In the other thread on here another person said he had problems also.

http://forum.unity3d.com/threads/93775-Beginning-3D-Game-Development-with-Unity/page19

The book is telling me to import assets for chapter four yet the source downloads start with chapter 7.

Hi Wampy,

I was able to reproduce the problem- most of the unzip was OK, but I think it is missing chapters 4-6 (which, of course are the first ones you will need…)

So I contacted my editor and she said they would have them up this weekend

if you PM me with an e-mail address, I can give you a dropbox link for the missing ones until they get the full download sorted out.

thanks for your patience!

Sue

Sue,

Is this book targed to developers working on a Mac or a PC (or both)? Does it use C# or UnityScript?

I’m primarily a PC developer, and I want to make sure the book would be OK for me to use. I realize Unity works on either, but that doesn’t mean the book isn’t heavily one or the other.

Thanks,
Harold Blackorby

According to the introduction, it was written using Windows 7 and 8 (and makes a note where there are differences on the Mac) so you should be fine. Looks like the code is all Javascript.

Great book so far! I think this will be a valuable resource in attempting to learn Unity.

Errata:

  1. Page 111, steps 9-11 talk about adding a tree, “Big Tree” to the scene. This asset is not available in the Standard Assets. If the intent is to download the book files to get this, there’s no mention of it, and at this point there hasn’t been any info on how to go about importing the asset into a project from the files even if they were downloaded. Later on page 114 there’s mention of downloading TerrainAssets.unitypackage from the store, however it appears this package is included with the Unity install and the one referenced on page 24, Terrains.unitypackage is not. So maybe thats the source of the error, i.e. Big Tree is part of Terrains not TerrainAssets which is now what is included with the install?

  2. Page 117, step 10 refers to selecting “Refresh Tree and Detail Prototypes” from the Terrain menu. Not sure what that means.

The below wasn’t technically Errata, but was confusing.

Page 113, step 1 instructs you to “Locate the Palm tree in the Project view and drag it into the Scene view”. The Palm Tree is in Standard Assets >> Terrain Assets >> Trees Ambient-Occlusion. But dragging it into the Scene view doesn’t work. After experimenting around it appears that you have to expand “Palm Tree” which is just a folder and drag the Palm Tree Import Settings inside there. When doing this is brings it in as its own game object and adds it to the hierarchy which, based on the text that follows must be the intent.

Hi Vorbeli,

Thanks for the errata report! I haven’t received my hard copy of the book yet, so I’m struggling with the page numbers :slight_smile:

Good catch on Big Tree!
Big Tree is included with TreeCreator.UnityPackage
It can be brought into an existing scene with Assets (the menu)>Import Assets> Tree Creator or right-click in the Project view)>Import Assets> Tree Creator
In the first edition, I had people build a tree, so had them bring that package in when they first set up the project
In the second edition, I had to cut the tree building part out and apparently forgot we needed the sample tree!

" Page 117, step 10 refers to selecting “Refresh Tree and Detail Prototypes” from the Terrain menu. Not sure what that means."
Unity removed the Terrain menu and spred the functionality throughout the Inspector
There is now a Refresh button next to the Edit Tree [ or Edit Details] button for trees and detail meshes, so if you change an asset (I think we adjust the Scale Factor for the Old Banyan Tree), it must be “refreshed” for the changes to be updated in the terrain.

Page 113, step 1 instructs you to “Locate the Palm tree in the Project view and drag it into the Scene view”.
should probably read:
Page 113, step 1 “Locate the Palm tree asset (blue box with paper icon), not the Palm folder, in the Project view, and drag it into the Scene view”.
If you are using Two Columns Layout, the Palm image will have an open arrow on its right side

I’ll move these corrections to the first post- thanks, again!

@ Harold

As Vorbeli mentioned, I used Windows for the book. The scripts are mostly JavaScript( or Unity’s version of it to be more precise)
There has been interest expressed in C# versions of the scripts, so if that is where your interest lies, I may be “converting” those

Sue

why it goes windowed after pressing new game
i’ve build it the “bug” is not in the editor

Edit>Project Settings>Player>Resolution and Presentation>Resolution>Default is Full Screen

there are also more settings/options there for Mac

Sue,

I’ve gotten myself to Chapter 12 and I’m slightly stuck. Under the “Activating the Action Message” subheading on page 473, you have a change to the useText nested If statement. Outside of the If statement you have,

//reset mouseover s
if (resetMO) GUI.Box(Rect(0,0, Screen.width, Screen.height), “”, customGUIStyle);

Unity doesn’t compile because there is not resetMO variable. I looked at your finished code for chapter 12 and it’s not on that line in GameManager.js

Should this just have been removed from the 2nd edition?

Hi Mike,

It looks like a bit of code I may have used just to track down a bug or something (couldn’t find it in version 1 either)- definitely doesn’t belong there!

If you remove the “if (resetMO)” part of the line, it essentially creates an invisible “button” over the whole screen
and that control blocks mouseovers…

delete or comment out at will - I’ll add it to errata

thanks!

Sue

Hi Sue All,

Just got my copy of “Beginning 3D Game Development with Unity 4” yesterday. Only been playing with Unity for a short time, mainly using online tutorials for Unity with C#. Decided to get the book and give it a proper go.

Have done a fair bit of application and web dev programming so I’m pretty comfortable with both Javascript and C#, not to much of a hassle to convert scripts. Which is exactly what I’ve been doing. Only got book yesterday so only up to Ch 3, so has been a simple matter of converting Javascript to C# as I go. Had a quick look through rest.

Sue, you mentioned you may be converting the scripts to C#. Have you been able to do any of this or is it something you’d like to do if you have the time? I only mention it as I’m doing it anyway I could send you copies, and if anyone else is doing the same thing maybe we could make it a group effort. Let me know if your interested.

Would help if I was able to get the resources though. Still having no luck downloading from Apress. Apress Server doesn’t support resuming downloads so even using download manager doesn’t help. 8hrs yesterday for just over 50%, then connection reset. If Apress can’t provide multi-file downloads is there anywhere else the resources can be downloaded from?

Thanks

Stu

Hi Stu,

I just got sucked into another project, so converting to C# just fell into the “if I have time” category. I would love your help on this! A group effort sounds great too! We could find a place to make them available to other readers who are interested. As you said, a lot of the conversion is pretty straight forward, but there are places that will need a bit of explanation as well.

PM me and I’ll give you the link to my dropbox folder for the assets. No project files for each chapter, but that will at least get you going. Apress just isn’t set up to handle those large Unity project files gracefully.

Thanks so much for your offer- timing is perfect!

Sue

I just finished the Quick Publish section of chapter 6. When running the exe it shows the OS cursor along with the GUI cursor. When I run it in the Unity game window it only shows the GUI cursor. Any ideas?

I just made an exe of that chapter’s project it works as expected. But I did glance through the chapter see where I have you create an object called “Script Holder” that holds a temporary script called “HideCursor.”

Since that script uses Screen.showCursor to turn the OS cursor off and on and I don’t see where I tell you to delete it once you start making the GUI cursor, I’m thinking that could be the problem.

So, if you still have a “Script Holder” object in the Hierarchy view, delete or deactivate it.
Let me know if that was the problem I’ll add that to errata.

thanks,
Sue

I deactivated the Script Holder object and it works as expected now. I still don’t understand why the problem didn’t show up until I built the executable.

Thank you for the quick reply.

On page 147 and page 156, references are made to Appendix B. Looks like the appendices didn’t make it into the printed book. Any chance of providing them online? I’m curious what A contains or if there are others beyond B :slight_smile:

@ Cooter - OS cursor hide/show in the editor has always been erratic, at least in Windows
I usually need to use full screen for Play mode to see if it is really working or not
good find on that one- I’ll add it to errata

@Vorbeli Ward- Appendix A was the images of a couple of shaders I built with the Strumpy Shader Editor. He’s gone pretty quiet lately, so guessing we might eventually see the editor as part of Unity at some point- total speculation on my part here

Appendix B was a list of the strings names of keyboard keys, Input.GetKey (“a”)
A short version can now be found by searching “Input” in the Manual

Appendix C was a list of what triggered what in the final sequence- it was rather like the grand finale of a fireworks show, where a lot of things happen in a short space of time.
Since the reader just imports the final level pretty much finished, I left it out also

So basically, in the interest of cutting way back on the page count, they weren’t included, but the decision was made toward the end so hte reference to B snuch through.

Sue

ok, sounds like it made sense to remove them for space. Here are some more I ran across. Really enjoying the book btw, great job! Its a great learning tool!


p.199 - step 6, in order to be able to change the default resolution (to get the width/height fields to show up) you first have to uncheck the “Default is Fullscreen” checkbox. Otherwise the fields aren’t available there to edit.

p.205, 208 - There are references to the Edit menu, Game Settings. This is actually Project Settings. Unity must have renamed it.

p.209 - When you get to this point, if you run the code the default hardware cursor will still get shown occasionally even though you’re using GUI.DrawTexture now for the cursor. This is because the HideCursor script (in the ScriptHolder game object) is still there and running. Even though we’re turning off the cursor at startup, HideCursor will still show it again. I think its necessary to remove this script at this point in the book so that the cursor will work properly.

p.209 - The AlmostBlankAlpha texture referenced here does not exist in the ch 6 downloaded assets. Having said that, these steps are not necessary provided you consider the above and remove the HideCursor script at this point.

p.212 - The sentence starting with, “Reading through the function, if it was passed a false…”, is backwards. Its stating the logical condition opposite of what it should be which might be confusing to someone without any scripting/coding experience.

1 Like