Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Game Development Book

Discussion in 'Community Learning & Teaching' started by Merries, Jul 24, 2009.

  1. shader

    shader

    Joined:
    Apr 4, 2009
    Posts:
    253
    Hi RHD

    Lovely graphics, what software did you use for the rooms ?
     
  2. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Thank you!

    SketchUp to model, Photoshop for textures, After Effects for the animated textures and LightUp to light and export to Unity.

    I'm looking into more sophisticated modelling software but I also want to learn a bit of scripting as that's holding me back at the moment so I've got a lot of work to do but the thing is it's fun!
     
  3. absolutebreeze

    absolutebreeze

    Joined:
    Feb 7, 2009
    Posts:
    490
    This is probably a real noobie problem, but I have spent a few hours rebuilding and recoding over and over trying to clear this error.

    Its at the end of Chapter 7.

    I should mention that I can go into the outpost, pick up the box of matches (that's when the error occurs), and as expected they disappear, then I can go outside and light the fire. The only odd thing is that once lit - the 2d matchbox does not clear from the HUD - however everything else seems to run fine.


    Code (csharp):
    1.     var matchGUIobj = Instantiate(matchGUI, Vector3(0.15,0.1,0), transform.rotation);
    2.     matchGUIobj.name = matchGUI;
    3.  
    Line 86 is the last line above.

    Has anyone else had this problem and if so - how did you get around it.

    Im sure the coding is fine - but I suspect I have something missing in the inspector somewhere.

    If it helps - here is my PlayerCollisions.js file..


    Code (csharp):
    1. private var haveMatches : boolean = false;
    2. private var doorIsOpen : boolean = false;
    3. private var doorTimer : float = 0.0;
    4.  
    5. var matchGUI : GameObject;
    6. var doorOpenSound : AudioClip;
    7. var doorShutSound : AudioClip;
    8. var batteryCollect : AudioClip;
    9.  
    10. function Update () {
    11.  
    12. var hit : RaycastHit;
    13.  
    14. if (Physics.Raycast (transform.position, transform.forward, hit,5)) {
    15.  
    16.         if(hit.collider.gameObject.tag=="outpostDoor"  doorIsOpen == false
    17.          BatteryCollect.charge == 4){
    18.         Door(doorOpenSound, true, "dooropen");
    19.         GameObject.Find("Battery GUI").GetComponent(GUITexture).enabled=false;
    20.         }
    21.        
    22.         else if(hit.collider.gameObject.tag=="outpostDoor"  doorIsOpen == false  BatteryCollect.charge < 4){
    23.         GameObject.Find("Battery GUI").GetComponent(GUITexture).enabled=true;
    24.         TextHints.message = "The door seems to need more power..";
    25.         TextHints.textOn = true;
    26.        
    27.         }
    28. }
    29.  
    30. if(doorIsOpen){
    31.         doorTimer += Time.deltaTime;
    32.    
    33.         if(doorTimer > 3){
    34.             Door(doorShutSound, false, "doorshut");
    35.             doorTimer = 0.0;
    36.         }
    37.     }
    38. }
    39.  
    40. function OnControllerColliderHit(hit : ControllerColliderHit){
    41.  
    42.     if(hit.collider.gameObject == GameObject.Find("campfire")){
    43.  
    44.             if(haveMatches){
    45.                                     haveMatches = false;
    46.                                     lightFire();
    47.            
    48.             }else{
    49.                     TextHints.textOn=true;
    50.                     TextHints.message = "I'll need some matches to light this camp fire..";
    51.             }
    52.  
    53.  
    54.         }
    55.  
    56.  
    57.     if(hit.collider == GameObject.Find("mat").collider){
    58.         CoconutThrow.canThrow=true;
    59.         }else{
    60.         CoconutThrow.canThrow=false;
    61.         }
    62.  
    63. }
    64.  
    65.  
    66. function Door(aClip : AudioClip, openCheck : boolean, animName : String){
    67.     audio.PlayOneShot(aClip);
    68.     doorIsOpen = openCheck;
    69.     var myOutpost : GameObject = GameObject.Find("outpost");
    70.     myOutpost.animation.Play(animName);
    71. }
    72.  
    73. function OnTriggerEnter(collisionInfo : Collider){
    74.    
    75.     if(collisionInfo.gameObject.tag == "battery"){
    76.     BatteryCollect.charge++;
    77.     audio.PlayOneShot(batteryCollect);
    78.     Destroy(collisionInfo.gameObject);
    79.     }
    80.    
    81.     if(collisionInfo.gameObject == GameObject.Find("matchbox")){
    82.     Destroy(collisionInfo.gameObject);
    83.     haveMatches=true;
    84.     audio.PlayOneShot(batteryCollect);
    85.     var matchGUIobj = Instantiate(matchGUI, Vector3(0.15,0.1,0), transform.rotation);
    86.     matchGUIobj.name = matchGUI;
    87.     }
    88.    
    89. }
    90.    
    91. function lightFire(){
    92. var campfire : GameObject = GameObject.Find("campfire");
    93. var campSound : AudioSource = campfire.GetComponent(AudioSource);
    94. campSound.Play();
    95. var flames : GameObject = GameObject.Find("FireSystem");
    96. var flameEmitter : ParticleEmitter = flames.GetComponent(ParticleEmitter);
    97. flameEmitter.emit = true;
    98. var smoke : GameObject = GameObject.Find("SmokeSystem");
    99. var smokeEmitter : ParticleEmitter = smoke.GetComponent(ParticleEmitter);
    100. smokeEmitter.emit = true;
    101. Destroy(GameObject.Find("matchGUI"));
    102. }
    103.  
    104. @script RequireComponent(AudioSource)
    I normally wouldn't be asking - but I'm going code blind after reviewing everything over and over and would really appreciate a little nudge in the right direction :)

    Thanks in advance.
     
  4. absolutebreeze

    absolutebreeze

    Joined:
    Feb 7, 2009
    Posts:
    490
    fixed it!

    I changed it too....

    matchGUIobj.name = "matchGUI";

    And the error cleared.

    Perhaps its a typo in the book. Strange that you do not get the same error though.

    Thanks for helping me with this.

    Tony
     
  5. asterix

    asterix

    Joined:
    Aug 1, 2009
    Posts:
    245
    breeze

    I commented matchGUIobj.name = matchGUI;
    cause it was givving me problems.
    The matches icon, don't worry the game end when you lit the fire. But it is a bug.
     
  6. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    AbsoluteBreeze - you need that to be in inverted commas, its a mistake that has been fixed in the final drafts, sorry about that.

    Code (csharp):
    1. matchGUIobj.name = matchGUI;
    should be -

    Code (csharp):
    1. matchGUIobj.name = "matchGUI";
    Where "matchGUI" is a string we are feeding as a name. Otherwise you're sending it a variable name or generic word that does not contain a string and indeed does not exist.

    All the best

    Will
     
  7. absolutebreeze

    absolutebreeze

    Joined:
    Feb 7, 2009
    Posts:
    490
    Thanks Will! much appreciated :)

    I also changed the routine slightly to not give the default message "I'll need some matches to light this camp fire.." even when the fire is lit.

    I declared this... at the top...

    Code (csharp):
    1.  
    2. private var spentMatches : boolean = false;
    3.  
    And then modified part of this function...

    Code (csharp):
    1. function OnControllerColliderHit(hit : ControllerColliderHit){
    2.  
    3.     if(hit.collider.gameObject == GameObject.Find("campfire")){
    4.  
    5.             if(haveMatches){
    6.                                     haveMatches = false;
    7.                                     lightFire();
    8.                                     spentMatches =true;
    9.            
    10.             } else if (spentMatches){
    11.            
    12.             TextHints.textOn=true;
    13.             TextHints.message = "I better not stand too close - this fires hot!";
    14.            
    15.             }
    16.            
    17.             else {
    18.                     TextHints.textOn=true;
    19.                     TextHints.message = "I'll need some matches to light this camp fire..";
    20.             }
    21.  
    22.  
    23.         }
    It's a great book!.... well - a fantastic book :)

    Thanks again.
    Tony
     
  8. absolutebreeze

    absolutebreeze

    Joined:
    Feb 7, 2009
    Posts:
    490
    When you log into your account you should see a downloads area on the main account page..

    Something like this.......

    Code Download 28 Sep 09 Unity Game Development Essentials [RAW]
     
  9. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Hi,

    Thanks. No, only the book download in my user account but I found it eventually through the support pages.
    It downloaded a zip file with a bunch of files called "code" and "revised code" and some Unity packages so I guess that's it.

    Thanks for the swift reply!
     
  10. moctezumagames

    moctezumagames

    Joined:
    Jun 9, 2009
    Posts:
    395
    got it!
    its a fair price, so I decided to buy it.
    You will know how the book looks like from a coding noob point of view :)
     
  11. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    I got it for the scripting and I've just started to read through it. It's great! It's the most sensible explanation for beginners I've ever seen. When I've got more time I'll load up the project files and start working through it but at the moment a lot of things are becoming clearer just reading the scripting chapters.

    It's always awkward as a non scripter asking for help on the forum because quite often I then have to ask the person who responds to explain the explanation. This is starting to bridge the gap. I've looked at a few online tutorials but Will's are the best. He is one of the few people who can clearly explain in sensible detail a complex subject. A lot of people waffle on endlessly over easy bits then skip over the key complicated stuff assuming you know that bit and leave you stranded.

    This book goes into even more detail than the tutorials and looks like it's actually going to explain the basics well enough to get me off the ground writing scripts. I'm so excited I can't tell you! I might be able to figure out how to get my doors to open at long last!

    Thank you Will!
     
  12. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi All, just a quick one to say a massive thank you to all of you for your support the past 10 months and to let you know that the book is finally finished and being printed this week!

    woot, hope it helps anyone reading this who is new to the joy of Unity devvin'!

    Will
     
  13. asterix

    asterix

    Joined:
    Aug 1, 2009
    Posts:
    245
    The last raw book is October 17Th is it the final?
     
  14. absolutebreeze

    absolutebreeze

    Joined:
    Feb 7, 2009
    Posts:
    490
    Congrats Will!

    It's great to hear that its finally hitting the shelves. I'm away for a couple of weeks, but I am really looking forward to having the book in my hands when I get back, even though I have already whipped through the ebook. :)

    For anyone else who is starting out in unity and wondering whether to buy! I whole heartedly encourage you to invest in it. Not only is it a great guide(and Will a great teacher!), but its going to be a useful reference book too - teaching stuff that can be applied to many different situations.

    And lets face it - you could spend more down the pub (or in a bar for our US friends) in one evening :)

    Go on...... you know you want to buy it!
     
  15. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    So, I guess you fancy a holiday now and not wanting to push, and I haven't even read/worked through this one yet, but how about a book for Unity iPhone version?
     
  16. harry101

    harry101

    Joined:
    Sep 3, 2008
    Posts:
    52
    In this threat Asterix asked:

    Did you found out why this was happening. I have seen through the book, but I can't find that I have done something different and still the door will not close the whole way.

    BR
     
  17. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    I've got exactly the same thing.

    Plus I couldn't get the ray-casting thing to work but I think I did not understand which bits of the script exactly to alter, or where to put the alterations.
     
  18. Merries

    Merries

    Joined:
    Feb 2, 2009
    Posts:
    262
    I ran into the Raycasting problem myself in Chapter 4 here is my code. Its not showing any errors.

    Code (csharp):
    1. private var doorIsOpen : boolean = false;
    2. private var doorTimer : float = 0.0;
    3. private var currentDoor : GameObject;
    4.  
    5. var doorOpenTime : float = 3.0;
    6. var doorOpenSound : AudioClip;
    7. var doorShutSound : AudioClip;
    8.  
    9. function Update () {
    10.     if(doorIsOpen){
    11.         doorTimer += Time.deltaTime;
    12.                
    13.     if(doorTimer > 3){
    14.         Door(doorShutSound, false, "doorshut", currentDoor);
    15.         doorTimer = 0.0;
    16.        
    17.     var hit : RaycastHit;
    18.         if(Physics.Raycast (transform.position, transform.forward, hit, 5)) {
    19.         if(hit.collider.gameObject.tag=="outpostDoor"  doorIsOpen == false){
    20.         currentDoor = hit.collider.gameObject;
    21.         Door(doorOpenSound, true, "dooropen", currentDoor);
    22.             }
    23.         }
    24.     }
    25.     }
    26. }
    27.  
    28. /*
    29. function OnControllerColliderHit(hit : ControllerColliderHit){
    30.     if(hit.gameObject.tag == "outpostDoor"  doorIsOpen == false){
    31.         currentDoor = hit.gameObject;
    32.         Door(doorOpenSound, true, "dooropen", currentDoor);
    33.         }
    34.     }
    35. */ 
    36.  
    37. function Door(aClip : AudioClip, openCheck : boolean, animName : String,
    38. thisDoor : GameObject){
    39.     audio.PlayOneShot(aClip);
    40.     doorIsOpen = openCheck;
    41.    
    42.     thisDoor.transform.parent.animation.Play(animName);
    43. }
    44. @script RequireComponent(AudioSource)
    45.  
    46.  
    47.    
     
  19. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Merries you total star!

    I had the var hit etc in the wrong place. Will says a couple of lines down from function update so I put if before if door etc instead of after.

    I will run through the exercise again and then compare it to yours.

    Thanks a million!!!
     
  20. Merries

    Merries

    Joined:
    Feb 2, 2009
    Posts:
    262
    I could not get mine to work and yours did not work when you put the function 'before' the door? Hum, not sure where to go from here.
     
  21. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    OH!
    Yours didn't work either? Mine came up with loads of errors but I was sure it was wrong because I was completely lost about where I was supposed to put the alterations although I sort of understood what they were for.

    Will needs a forum for his book so we can figure these things out.
     
  22. Merries

    Merries

    Joined:
    Feb 2, 2009
    Posts:
    262
    Battery GUI textures missing?

    In chapter 5 I went over the folders carefully and there are no battery.jpg for the GUI am I missing them somewhere?
     
  23. Merries

    Merries

    Joined:
    Feb 2, 2009
    Posts:
    262
    If anyone is missing the battery textures I made some up. They are attached. Hope they are ok.
     

    Attached Files:

  24. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Thanks Merries!
     
  25. Merries

    Merries

    Joined:
    Feb 2, 2009
    Posts:
    262
    Here is the script that works for Raycasting in Chapter 4 prior to adding on the Battery GUI bits.

    Code (csharp):
    1. private var doorIsOpen : boolean = false;
    2. private var doorTimer : float = 0.0;
    3. private var currentDoor : GameObject;
    4.  
    5. var doorOpenTime : float = 3.0;
    6. var doorOpenSound : AudioClip;
    7. var doorShutSound : AudioClip;
    8. /*
    9. function OnControllerColliderHit(hit : ControllerColliderHit){
    10.     if(hit.gameObject.tag == "outpostDoor"  doorIsOpen == false){
    11.         currentDoor = hit.gameObject;
    12.         Door(doorOpenSound, true, "dooropen", currentDoor);
    13.         }
    14.     }
    15. */ 
    16.  
    17. function Door(aClip : AudioClip, openCheck : boolean, animName : String,
    18. thisDoor : GameObject){
    19.     audio.PlayOneShot(aClip);
    20.     doorIsOpen = openCheck;
    21.     thisDoor.transform.parent.animation.Play(animName);
    22. }
    23.  
    24.  
    25. function Update () {
    26.  
    27. var hit : RaycastHit;
    28.    
    29.         if(Physics.Raycast (transform.position, transform.forward, hit, 5)) {
    30.         if(hit.collider.gameObject.tag=="outpostDoor"  doorIsOpen == false){
    31.         currentDoor = hit.collider.gameObject;
    32.         Door(doorOpenSound, true, "dooropen", currentDoor);
    33.             }
    34.     if(doorIsOpen){
    35.         doorTimer += Time.deltaTime;
    36.                
    37.     if(doorTimer > 3){
    38.         Door(doorShutSound, false, "doorshut", currentDoor);
    39.         doorTimer = 0.0;
    40.    
    41.         }
    42.     }
    43.     }
    44. }
    45.  
    46.  
    47.  
    48.  
    49.  
    50. @script RequireComponent(AudioSource)
    51.  
    52.  
    53.    
     
  26. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Fantastic!

    Thanks again Merries!
     
  27. Danneman

    Danneman

    Joined:
    Sep 29, 2009
    Posts:
    190
    Im thinking about buying the book, but have one question first: what program is used to model the objects?

    Is it the same as in the video-tutorials, ie. cinema 4d? Although it looks like a great program, it seems unnecessary to use such an expensive program when for instance blender is available. It definitely seeds out the amateurs without the cash to spend on yet another tool - which should probably be the people most interested in such a book...
     
  28. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    It doesn't address the modelling, it's about Unity.
     
  29. Merries

    Merries

    Joined:
    Feb 2, 2009
    Posts:
    262
    Yes Danneman its all about building a game in Unity and goes into alot of detail on that. The model assets are provided free when you get the ebook.

    And honestly, as long as your modeling program (free or paid) does what you want and exports in the right format it does not matter which one you use. AC3D is a low cost basic modeler and does a great job. But if your a generalist and want animation, rendering and the whole kit and caboodle go with Blender if you can deal with the Interface or check out Modo. Modo does not have character animation yet but they are close to putting it in, just released the IK and animation keyframe setup.
     
  30. Danneman

    Danneman

    Joined:
    Sep 29, 2009
    Posts:
    190
    So no coverage at all of modelling and animation? Thats a shame, because despite my objections to the selection of the tool it was very comprehensive and pedagogical (yes, I realize Im sending mixed signals ;) ).

    Yes, Im a generalist, but youre right, Blenders interface is dreadful. Ill have a look at Modo and hope they get animation going soon.

    Thanks for the info, and great job on the video-tutorials. Based on their quality Im certainly getting this book...and either way it feels gratifying to support someone who contributes so much to the community :)
     
  31. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi guys just wanted to address the points raised here.

    First off - is the battery pack is in the downloadable assets, and I've just double checked that the textures work with a new project from scratch - it definitely does - what are you guys experiencing?

    Secondly, there is nothing wrong with the approach with regard to raycasting, but it seems theres a glitch with the original model causing it not to shut entirely - this is purely cosmetic and we'll hopefully upload an amended model soon but it really doesn't make any odds in terms of functionality so don't fret about your code being wrong guys!

    Any other issues keep em coming although I hope there won't be any we spent a ton of time checking and double checking the book.
     
  32. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Hi Will,

    Thanks!

    About the raycasting, I just got completely lost over where the script additions to do this were supposed to go. Your explanations are usually the best around, but here I got totally lost.
     
  33. Passero

    Passero

    Joined:
    Oct 7, 2009
    Posts:
    63
    I bought the book yesterday and just reached page 123 :)
    It reads quiet nice and the explenations are good.

    Perhaps one thing you could at (or maybe i overread it...). People who have a more programming background (webdevelopment) it could be misleading that all the On... functions are with an uppercase. In normal javascript all the on function like onMouseClick and so on are with a lower case. Normal standards dictacte that functions are with lowercase and classes with uppercase. Perhaps it would be a good idea to mention this in the book as a tip or cautionbox or what ever :)
    I just spend an hour looking for my mistake because the onControllerColliderHit wouldn't fire than i noticed it was OnControllerColliderHit :).
     
  34. DavidT

    DavidT

    Joined:
    Oct 12, 2009
    Posts:
    16
    Any chance the book will be on sale at Unite '09? I'm coming from Australia and would prefer to pick it up at the conference rather than ship it.
     
  35. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi guys

    just a quick update - sorry I only recently realised in a sudden moment of clarity which textures you guys were asking for - not the batteries but the battery GUI textures, so yes, either mine or the publisher's bad, either way, they have now been updated and are in the code pack.

    Unfortunately I can't afford to go to Unite so to my knowledge the book won't be on sale there, i'd love to go its just too much expense for me at the moment, hope you all have a great time there

    Will
     
  36. Danneman

    Danneman

    Joined:
    Sep 29, 2009
    Posts:
    190
    I just got your book (pdf + hardcover bundle) and its a great piece of work so far :)

    However, I thought Id finish the video-tutorials first to get a good overview, and one thing that confused me was the description of static variables in around lesson 4.

    You say that static variables differ from regular ones in that they are accessible from other scripts. Are regular variables not accessible, then? Since its javascript, and all variables placed outside a function are global, this would mean that despite using static it is accessible. And in fact, trying it out removing "static" from for instance the script GemCollect in lesson 4 still works as it should.

    Perhaps your confusing javascript with c#, because the keyword "static" has a similar functionality in c# - making it accessible from other objects without the need of an instantiation.

    Or is there some other difference that Im not aware of, or have understood incorrectly?

    I did however notice one thing when declaring a static variable in js - it no longer turned up in the inspector as regular variables do. So if you want to hide the variable (which would be appropriate for counters, for intstance), using static seem to be the thing.
     
  37. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    All variables are ultimately members of the script in javascript, the script name being the class itself. My video tutes are ageing a little now and when i did them i may have misunderstood the issue of globals in unity js as i was new to unity at the time and coming from a director lingo background, hoping to do some more up to date tutorials soon now the book is out of the way, seems to be a lot of iphone requests so may do something with that.
     
  38. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Please do!

    You do the best explained tutorials and books I've ever seen!

    Hope the book sells well!
     
  39. Danneman

    Danneman

    Joined:
    Sep 29, 2009
    Posts:
    190
    I second that request - having read countless tutorials and books on various computerrelated subjects over the last couple of years I can conclude that a really good tutor is a rare thing indeed. Youve got a real talent for describing stuff in an eloquent and digestible manner :)

    I couldnt help noticing that on your download-page you have an additional project referring to yet another lesson - lesson 6. Does this mean there is an unfinished lesson in the pipeline (or forgotten), or is this simply the completed project for lesson 5?

    [edit]
    Forgot to mention - there seems to be something wrong with the game-file at the end of all the lessons. Keep getting an error regardless of browser (with unity3d-plugin). Thought youd want to know.
     
  40. christopherbrown

    christopherbrown

    Joined:
    Oct 19, 2009
    Posts:
    83
    Thanks to AbsoluteBreeze and willGoldstone for the matchGUI discussion. I was beginning to pull my hair out and bleed from my eyes!

    BTW, as of today, this issue does not appear in the errata for the book on the Packt Publishing website. Is it a known submission? If so, about how long does it take them to process each submission? I'd hate to think early adopters of the book are sharing problems and solutions here but not submitting them to the publisher! :eek:

    Thanks again, all.
     
  41. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi guys sorry for late reply been away and am generally immensely busy at the mo so sorry this must be brief!

    Danneman - I usually teach Unity as a 6 lesson structure but never got round to recording lesson 6, but it does exist in theory! The book however goes beyond the stuff covered in my videos so really I don't have plans to expand on the video tutorial structure as is, any new video tutes I do will be on fresh subjects.

    Christopherbrown- that errata is indeed with the publisher and we are working on a solution currently, thanks for the reminder though, good clarification.

    All the best guys, sorry again its brief!

    Will
     
  42. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    I got the book today and read the first chapter, it is very nice and enjoyable. I would have read more but I am really really really etc. tired. So I will do more tomorrow and start learning game creation with unity3d Yay.
     
  43. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    My book's arrived!

    It's a proper book and it stays open at the page you want when it's perched on the keyboard in front of you.

    Hate those stiff ones that close up the whole time and you loose your page.
     
  44. oliver_l1

    oliver_l1

    Joined:
    Oct 5, 2009
    Posts:
    4
    so far a good book for beginners.currently i am reading chapter 4 and i have a "scaling" problem.The author writes:
    i've changed the scale factor to 2 but after that the "outpost" is looking weird and cluttered.

    edit:
    i think the factor of 1 should not be changed instead i've changed the scale of the first person controller to 0.7,0.5,0.7 and voila it worked:)

    now i can walk upstairs open the door and go inside the "outpost".

    yeah this is learning by doing what a great experience


    :D
     
  45. InternetCodesmith

    InternetCodesmith

    Joined:
    Oct 29, 2009
    Posts:
    26
    Hi Will,

    Just wanted to comment and say that your book is well written, and extremely easy to follow (my 8 year old is enjoying it, too!) I have already recommended it to my team members (so I know you have at least 2 sales from Amazon)

    Thanks!

    Jonathan
     
  46. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    I must say, I love your book. It indeed helps me with Unity3d a lot. Thanks.
     
  47. jnbutler

    jnbutler

    Joined:
    Dec 1, 2009
    Posts:
    16
    I am new to Unity 3D and looking forward to getting into the your book Will. I bought the e-book bundled with the Blender e-book since I will be learning Blender along side of Unity. From all the posts sounds like it is a great resource, thanks.
     
  48. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Me too!

    I finally got my doors to open! Thank you!
     
  49. Dieneces

    Dieneces

    Joined:
    Aug 1, 2009
    Posts:
    26
    I bought the book in RAW a fw months ago, but only today start to read it #)

    Going on page 150 without any problem or doubt (related to the matters in explained) :p

    Wonderful work, truly a must have to newbies!

    Now please start writing an advance continuation ;)
     
  50. Raptor5399

    Raptor5399

    Joined:
    Sep 25, 2007
    Posts:
    94
    Well you got a few pages farther than me ;)

    Im on page 148 and having trobule with null reference exceptions when I get within raycast hit distance of the door. The trouble started on page 144 with
    GameObject.Find("Battery GUI").GetComponent(GUITexture).enabled = true;

    Now that line is on line 20 in my script, also line 17 where it is set to false and I have seen a null reference associated with that line as well, though I get tons and tons of them for line 20 once I go up to the door.

    My thought is that since the Battery Collect script attached to Battery GUI turns that component off (the gui texture) with the start function function Start(){
    guiTexture.enabled = false;

    that I would get null reference exceptions because the thing does not exist at the time. Of course I have to be wrong somehow, otherwise it would be fixed. Anyone know whats wrong?

    private var doorIsOpen : boolean = false;
    private var doorTimer : float = 0.0;
    private var currentDoor : GameObject;

    var doorOpenTime : float = 3.0;
    var doorOpenSound : AudioClip;
    var doorShutSound : AudioClip;
    var batteryCollect : AudioClip;

    function Update () {

    var hit : RaycastHit;
    if(Physics.Raycast (transform.position, transform.forward, hit, 3)){
    if(hit.collider.gameObject.tag == "outpostDoor" doorIsOpen == false BatteryCollect.charge >=4){
    currentDoor = hit.collider.gameObject;
    Door(doorOpenSound, true, "dooropen", currentDoor);
    GameObject.Find("Battery GUI").GetComponent(GUITexture).enabled = false;
    }
    else if(hit.collider.gameObject.tag == "outpostDoor" doorIsOpen == false BatteryCollect.charge <4){
    GameObject.Find("Battery GUI").GetComponent(GUITexture).enabled = true;
    TextHints.message = "The door seems to need more power. . .";
    TextHints.textOn = true;
    }
    }

    if(doorIsOpen){
    doorTimer += Time.deltaTime;
    if(doorTimer > doorOpenTime){
    Door(doorShutSound, false, "doorshut", currentDoor);
    doorTimer = 0.0;
    }
    }
    }

    /*
    function OnControllerColliderHit(hit : ControllerColliderHit){
    if(hit.gameObject.tag == "outpostDoor" doorIsOpen == false){
    currentDoor = hit.gameObject;
    Door(doorOpenSound, true, "dooropen", currentDoor);
    }
    */

    function Door(aClip : AudioClip, openCheck : boolean, animName : String, thisDoor : GameObject){
    audio.PlayOneShot(aClip);
    doorIsOpen = openCheck;
    thisDoor.transform.parent.animation.Play(animName);
    }
    function OnTriggerEnter(collisionInfo : Collider){
    if(collisionInfo.gameObject.tag == "battery"){
    BatteryCollect.charge++;
    audio.PlayOneShot(batteryCollect);
    Destroy(collisionInfo.gameObject);
    }
    }

    @script RequireComponent(AudioSource)