Unity 3D Game Development by Example

Ryan

I will love to have your feedback in this thread please

http://forum.unity3d.com/threads/63615-Writing-a-Book-on-Game-Developing-Need-critical-feedback-on-Unity

As Unity has really struck me like lightning Bolt, I am sure going to check out both the books.

Wicked Sunny

I bought the book recently have have slowly been going through it. It has been amazingly helpful in finding my way around unity.

Inside of it it mentions that the projects are already built and available at packtub (chapter 8 description). Packt only seems to have the assets available for download though and not the code itself. Was wondering if anyone could direct me to where these files are?

Ecoe - sorry for the delay. These files didn’t get uploaded when the book was published, but i’m working hard to make sure they’re available this week.

  • Ryan

Hey Ryan,

Thanks for the great book, i bought it sunday and i hope it will get me some programmer moves (i’m a graphical (3D) desinger)
I followed the steps in youre book (not really getting “it” though, i hope it will sink in soon, Would be a whole bunch easier if it was in dutch ) but im stuck in chapter 5.

I neatly typed the code but nothing is happening, i guess its due the fact i use a dual monitor set-up but i could also be about complety different (maybe earth rays interfer with my script)

here is my script:
It didnt give any compiler errors so im not sure whats going on. (and i get a lot of compiling error because of me Speeling and the wrong UsE of Capitals, dyslected poor me:( )

*_

Any enlightment would be vey much apriacated!
Thnx,
AAlan

Thank you for the update Untold.

adminsmithee, quick thing that I noticed in your script that is causing it to draw nothing is you didn’t capitalize OnGUI. You also call build grid twice.

Thanks Ecoe,

I changed the script as you suggested, but still no cake :frowning:
When i digged a little deeper i couldn’t find anything wrong.
I suddenly had a epiphany and attached the script to the camera and that did the trick :slight_smile:

hurray, one step closer to build a ultimate WOW (mine will have jet fighters and dragons as well as giant robots with laser vision) :slight_smile:

thanks for the help!

Edited/Solved…simple typo!

I am wondering if this is similar to Will Goldstones book, or if its the next level? I devoured Unity Game Development Essentials in less than a week.

Should I get this book or just go out on my own?

What is “a keep-up game”? That’s the first one on your list for 3D category of game.

halfway through the book.
I really like the topics in this book and how they are implemented.
Maybe the coding step in robot repair is a bit too large for me. How would I ever have thought of a structure like that to begin with?(all the arrays and grids) :slight_smile:
Next time, maybe tone the methaphors and childrens book comments down, they really annoy me. Especially when Im frustrated about something. Its like Clipper (from Word), who is not helping when u are angry :slight_smile:
all in all a nice book, and by author thoroughly explained.

are the examples in the book applicable to Unity 3.0 as is without any modifications?

thank you

edit -----

read through more carefully and found my answer, sorry about that

I purchased the book a few days ago and have made it through to chapter 7. Your simple examples and step-by-step instructions make this a great tutorial. Just what I needed to get an intro to Unity.

I do have a question. I am using Unity 3.0. I ran into a problem adding a true type font to a material as instructed on page 185, step 7. Simply, my selection list shows only the graphics. No fonts that have been imported show up. Is there an extra step I missed?

Thanks!

Well done! The book is a nice collection for my Kindle. I like the format of step by step tutorials. I just finished the Robot Repair project by converting the JavaScript to the C# without any problems. I am starting the Shoot the Moon project. By following the step by step instructions, I understand on how to use two cameras in the project.

I get an error for the “D2” part in the ClockScript page 190

"
minutes = timeRemaining/60;
seconds = timeRemaining % 60;
timeStr = minutes.ToString()+“:”;
timeStr += seconds.ToString(“D2”);
guiText.text = timeStr;//display the time to the GUI
"

Says the ‘specified format is invalid’

Hi there…firts of all, congrats for your book.
Right now I´m stuck with the “Robot repair” project. I´ve been getting the same error: “ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count” on line 66.

This is the code:

var cols : int = 4;
var rows : int = 4;
var totalCards : int = 16;
var matchesNeededToWin : int = totalCards*0.5; // If there 16 cards, the player needs to find 8 matches to clear the board
var matchesMade : int = 0; //At the outset, player has not made any matches
var cardW : int = 100;
var cardH : int = 100;
var aCards : Array; // We store all cards in this Array
var aGrid : Array; // Thisarray will keep track of the shuffled, dealt cards
var aCardsFlipped : ArrayList; //This array will store two cards that the player flips over
var playerCanClick : boolean; //prevent player clicking buttons when we don´t want to
var playerHasWon : boolean = false;
function Start ()
{

  • playerCanClick =true; *

  • aCards = new Array ();*

  • aGrid = new Array ();*

  • aCardsFlipped = new ArrayList ();*

  • BuildDeck();*

  • for (i=0; i<rows; i++)*

  • {*
    _ aGrid = new Array ();//create a new array at index i_

* for (j = 0; j<cols; j++)*
* {*
* var someNum : int = Random.Range (0,aCards.length);*
_ aGrid [j] = aCards [someNum];
* aCards.RemoveAt (someNum);
}
}
}
class Card extends System.Object
{
var isFaceUp : boolean = false;
var isMatched : boolean = false;
var img : String;*_

* function Card (img: String)*
* {*
* this.img=img; *
* }*
}
function OnGUI ()
{
* GUILayout.BeginArea (Rect (0, 0, Screen.width, Screen.height));*
* BuildGrid();*
* GUILayout.EndArea(); *
* print (“building grid!”);*
}
function BuildGrid ()
{
* GUILayout.BeginVertical ();*
* GUILayout.FlexibleSpace();*
* for (i=0;i<rows; i++)*
* {*
* GUILayout.BeginHorizontal ();*
* GUILayout.FlexibleSpace();*
* for (j=0;j<cols;j++)*
* {*
_ var card : Object = aGrid [j];
* if (GUILayout.Button (Resources.Load (card.img) , GUILayout.Width (cardW)))
{
Debug.Log (card.img);
}
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal ();
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}

function BuildDeck ()
{
var totalRobots : int = 4; //we have 4 robots to work with*

* var card : Object; //this stores a reference to a card*
* for (i=0; totalRobots<0; i++)
{
var aRobotParts : Array = [“Head”, “Arm”, “Leg”];
for (j=0;j<2;j++)
{
var someNum : int = Random.Range (0, aRobotParts.length);
var theMissingPart : String = aRobotParts [someNum];
aRobotParts.RemoveAt (someNum);*_

* card = new Card (“robot”+ (i+1) +“Missing”+ theMissingPart);*
* aCards.Add (card);*

* card = new Card (“robot”+ (i+1) + theMissingPart);*
* aCards.Add (card);*

* }*
* }*

}
Any help?
Thanks!!

Seems like line.1 is wrong.

[I]var cols : int = 4;

Delete headmost of line,.

Kudos on the book,

I was looking for a good place to start learning Unity and this thread lead me to the book so I bought it!

Thanks everyone.

-Larry Charles.:sunglasses:

Krodil - That is one bizarre error. i had the same problem with “D2” myself when i tried working with the code in Unity 3.0. Then someone i know tried it out, and there was no issue. Then i tried it out myself once more, on a different machine, with no trouble. And now you say it doesn’t work.

i’ve asked around, and conventional wisdom says that “D2” to round to two decimal places works just fine in both versions. i’m really curious to get to the bottom of this … i’ll let you know if i find out.

Pixelmoon - i submitted an erratum for this section. Essentially, Unity javascript doesn’t like that i tried to do math while setting the values of fields. Try one of two things:

  1. Hard-code the values, wherever they involve using the values of other variables. So instead of this:

var matchesNeededToWin : int = totalCards * 0.5;

do this:

var matchesNeededToWin : int = 8;

OR

  1. Declare the fields at the top, and define them in either the Start or Awake functions. So you’d split that line up like this:

var matchesNeededToWin : int; // the variable is declared here (a space is reserved for it in memory)
// other variables are declared here
// …
// …

function Awake()
{
matchesNeededToWin = totalCards * 0.5; // the value is defined here (we put something in the bucket)
}

Hope that helps! Sorry for the slip-up.

  • Ryan

Hi Ryan…thanks for the reply.
I´ve tried both but the same error persists…pretty sure I´m missing something but I don´t know what it is. Here´s the code as I´ve changed:

var cols : int;
var rows : int;
var totalCards : int;
var matchesNeededToWin : int; // the variable is declared here (a space is reserved for it in memory)
var cardW : int;
var cardH : int;
var aCards : Array; // We store all cards in this Array
var aGrid : Array; // Thisarray will keep track of the shuffled, dealt cards
var aCardsFlipped : ArrayList; //This array will store two cards that the player flips over
var playerCanClick : boolean; //prevent player clicking buttons when we don´t want to
var playerHasWon : boolean = false;

function Start ()
{
var cols : int = 4;
var rows : int = 4;
var totalCards : int = 16;
var matchesNeededToWin : int = 8; // If there 16 cards, the player needs to find 8 matches to clear
var matchesMade : int = 0; //At the outset, player has not made any matches
var cardW : int = 100;
var cardH : int = 100;
playerCanClick =true;
aCards = new Array ();
aGrid = new Array ();
aCardsFlipped = new ArrayList ();
BuildDeck();

for (i=0; i<rows; i++)
{
aGrid = new Array ();//create a new array at index i

  • for (j = 0; j<cols; j++)*
  • {*
  • var someNum : int = Random.Range (0,aCards.length);*
    _ aGrid [j] = aCards [someNum];_
    * aCards.RemoveAt (someNum);*
    * }*
    * }*
    }
    class Card extends System.Object
    {
    * var isFaceUp : boolean = false;*
    * var isMatched : boolean = false;*
    * var img : String;*

* function Card (img: String)*
* {*
* this.img=img; *
* }*
}
function OnGUI ()
{
* GUILayout.BeginArea (Rect (0, 0, Screen.width, Screen.height));*
* BuildGrid();*
* GUILayout.EndArea(); *
* print (“building grid!”);*
}
function BuildGrid ()
{
* GUILayout.BeginVertical ();*
* GUILayout.FlexibleSpace();*
* for (i=0;i<rows; i++)*
* {*
* GUILayout.BeginHorizontal ();*
* GUILayout.FlexibleSpace();*
* for (j=0;j<cols;j++)*
* {*
_ var card : Object = aGrid [j];
* if (GUILayout.Button (Resources.Load (card.img) , GUILayout.Width (cardW)))
{
Debug.Log (card.img);
}
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal ();
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}

function BuildDeck ()
{
var totalRobots : int = 4; //we have 4 robots to work with*
* var card : Object; //this stores a reference to a card*
* for (i=0; totalRobots<0; i++)
{
var aRobotParts : Array = [“Head”, “Arm”, “Leg”];
for (j=0;j<2;j++)
{
var someNum : int = Random.Range (0, aRobotParts.length);
var theMissingPart : String = aRobotParts [someNum];
aRobotParts.RemoveAt (someNum);*_

* card = new Card (“robot”+ (i+1) +“Missing”+ theMissingPart);*
* aCards.Add (card);*

* card = new Card (“robot”+ (i+1) + theMissingPart);*
* aCards.Add (card);*

* }*
* }*

}
Anyway, I´ll stay tuned for the erratum.
Thanks!!