Search Unity

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

Beginning 3D Game Development with Unity 4

Discussion in 'Community Learning & Teaching' started by k3D-Junkie, Sep 10, 2013.

  1. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Hi ruslander

    Copy on its way.
     
  2. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Thanks, christianorwood - what a stupid mistake and then not to see it! All now working ok.
     
  3. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Hi Sue

    At the bottom of page 543, surely you have to deactivate inventory icon objects after clicking play, not before?
     
  4. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Hello Sue, or anyone else. Starting the book again and i am stuck on page 208 ( again )

    Book read as follows -

    8. Wrap the DrawTexture code into the navigation conditional:

    if (!navigating) { // if not navigating
    var pos : Vector2 = Input.mousePosition; //get the location of the cursor
    GUI.DrawTexture (Rect(pos.x, Screen.height - pos.y,64,64), currentCursor);
    // draw the cursor }

    What is the navigational conditional? Do you mean this stuff in the Update function in the GameManager? What does the entire function look like when this code is "wrapped" in?

    Thanks in advance

    Steam Bucky
     
  5. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Stand down - the answer to my question is yes.

    I wish i knew why code daunts me so. That said, i push through, slowly learn a thing or two and move on. :>
     
  6. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Chapter 7 - Importing assets

    Nothing wrong, just as a 3d/2d artist i am really appreciating the chapter. Thanks.
     
  7. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Page 246 - "4. Locate the pollen ball at the bottom of the Bone07 hierarchy and select it. It is using a material called PollenBall." -

    I did see someone else had the same issue, but i can't find it PollenBall even with searching. Advice?
     
    Last edited: Mar 28, 2014
  8. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Ok, I am getting some errors on page 275

    I am adding in this code o my aniTest script:

    if (GetComponent(AudioSource)) {
    yield new WaitForSeconds(audioDelay);
    audio.Play();
    }

    ----------
    This is what my entire function looks like:
    ----------

    var aniParent : GameObject;
    var aniClip : AnimationClip;
    var audioDelay : float = 0.0;

    function OnMouseDown () {

    print(name + " picked using " + aniClip.name);

    aniParent.animation.Play(aniClip.name);

    //if (GetComponent(AudioSource)) audio.Play(); // play the default audio clip

    if (GetComponent(AudioSource)) {
    yeild new WaitForSeconds(audioDelay);
    audio.Play();
    }
    }


    -----
    The errors i am getting are:

    Assets/Adventure Game Assests/Adventure Scripts/AniTest.js(15,22): UCE0001: ';' expected. Insert a semicolon at the end.

    Thing is, that line of code does have a semi colon at the end

    yeild new WaitForSeconds(audioDelay);

    ...any ideas?
     
  9. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Did you sort this? If not Open the Flower object in the Hierarchy, click on Bone01, Bone02, etc until you get to Bone07. You will find the pollen ball in the Bone07 folder.

    This was meant to be a reply to your query on page 246
     
    Last edited: Mar 28, 2014
  10. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Try yield instead of yeild
     
  11. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Hi Sue

    There are a couple of references to the State Management PDF which don't appear in the copy I have downloaded from the Apress site; these are to data for Chapter 12 and Chapter 14. Am I missing something, if so where can I find it?
     
  12. Gaugeforever

    Gaugeforever

    Joined:
    Mar 12, 2014
    Posts:
    9
    Hello Sue and everyone else,

    I have the hard copy of the book, second edition. I don't know if this matters, but I thought it was worth mentioning. unto my problem.

    I'm currently on page 280, dealing with manually adding animations. Unfortunately this system, the Animation Window, has been changed in the newest form of Unity so much that I'm finding it difficult to make my way through it. Is there any way you, or someone else, could toss up a quick rewrite of this section for the newest Unity version?

    Really good book for beginners though so far. I think Chapter 6 could use some tweeks as it gets confusing. But really well done overall.

    EDIT: OK nvm, it appears you just add the curves right off for position. It is a bit different but I'm working my way through it.
     
    Last edited: Mar 29, 2014
  13. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Doh! Thanks mate!
     
  14. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    $nopollenball.png

    Nope...its just not there...

    If i report my flower object, will it screw anything up?
     
  15. Gaugeforever

    Gaugeforever

    Joined:
    Mar 12, 2014
    Posts:
    9
    That is odd, it's supposed to be there under Bone07, try reverting your flower, you have to do this a few times anyways. Be sure you didn't move the pollen ball somewhere else on accident.
     
  16. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Thanks for posting that, I thought i was going crazy! :)
     
  17. Gaugeforever

    Gaugeforever

    Joined:
    Mar 12, 2014
    Posts:
    9
    when the book tells you to change the wrap mode, you need to select the animation clip in the project view and change it in the inspector, this has also changed and was very frustrating to find.

    Currently I'm having trouble getting the alpha channel to work.
     
  18. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Thats the bit i am stuck on mate - I am working on it right now. If i have any luck I will PM you and post here. If you wanna chat via Skype to see if we can work this out PM me.
     
  19. Gaugeforever

    Gaugeforever

    Joined:
    Mar 12, 2014
    Posts:
    9
    PM you my skype info :) hopefully we can solve this together :D

    It appears you can make the curve, but when you move the recording line the value never changes from 1, even though the curve is clearly NOT at 1. Although when you do the same on position, the Y position IS moving. I'm just having a rough time getting past this one.
     
  20. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Last edited: Mar 29, 2014
  21. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Weird - Last time i downloaded them, they were in there. You have downloaded the file from the apress site.

    http://www.apress.com/9781430248996

    If they still aren there i'd email Apress direct. They are pretty good, though they probably won't get back to you on the weekend. Failing that you could always PM the books author on here. She started the thread.
     
  22. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    If revert doesn't work, give me an email address and I'll mail you my version (which does work!)
     
  23. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Hi Steambucky

    If reverrt doesn't work, give me an email address and I'll mail you my version (which does work!")
     
  24. Gaugeforever

    Gaugeforever

    Joined:
    Mar 12, 2014
    Posts:
    9
    I assume he got it working as we were working through a later chapter together last night.
     
  25. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    I just skipped it - could you send it to me at marc_buckingham@me.com? Thanks.
     
  26. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Does anyone know if all the errata is up to date and in one place?
     
  27. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    The only place to find errata is on this site, but you have to read through it from end to end because none of it is sorted.
     
  28. Gaugeforever

    Gaugeforever

    Joined:
    Mar 12, 2014
    Posts:
    9
    So yea, like steambucky, I am pretty much done with this book. The errors start really piling on later in the book. I'm just over halfway through and I'm just tired of fighting the errors. The same errors everyone else is having, errors that have NOTHING to do with the unity version.

    It's very clear to me that the author did not proofread this book very well, or do their own project while reading through this book. ANYONE, would have been able to spot these errors. Starting on chapter 9 there is an object you need to mess with that pops up out of thin air. It was not created or imported prior to that chapter.

    It is my thought that most people probably only did the first 4 chapters before reviewing this book, otherwise they would have had an entirely different opinion of it. Youtube videos are more concise then this, and you don't have to pay for those. I'm sorry to be so harsh, but for a book so highly rated, it is utter garbage later on. A published book should not be this rife with errata that is within the control of the author.
     
  29. GameTech

    GameTech

    Joined:
    Dec 26, 2012
    Posts:
    53
    Hi i bought the unity 3 version of the book. Are we able to use the assets and scripts in a commercial game? If not, can we at least use them for a free game we publish online?
     
  30. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Sadly I have to agree with Gaugeforever. It is a great shame that what could be a really good introduction to Unity game development has been ruined by such sloppy checking and I hope Sue and Apress can between them republish a book that is fit for purpose and provide previous purchasers with a complimentary copy.
     
  31. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    hi guys- sorry for being MIA- working on new book and you will be happy to hear my new tech reader is top-notch (I don't think the last one even worked through the project)

    I've got a couple more days before I can catch up with questions errata
     
  32. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    also, Apress have finally figured out a way to break the asset downloads into several files!

    @SteamBucky- I looked in my chapter 16 project see the Pollen Ball as a child of Bone07, showing below PBone17

    Tony others, thanks much for helping out here!

    Sue
     
  33. Gaugeforever

    Gaugeforever

    Joined:
    Mar 12, 2014
    Posts:
    9
    This is unfortunate for those of us who have already purchased the book. Do you have a timeline on the new book? Also would it be possible for those of us who have this book (who can verify it) to get a discount on the new one. This book without errors would be simply fantastic. I mean I understand some errors happen. For a book this large, you have to expect it, but... yes, as you said, there is no way anyone did that project while proofreading the book. I think it would be the right thing to do to offer those of us with this current edition a discount on the new one.

    Working through version issues is fairly easy. Usually a trip to Unity answers and 5 minutes will yield a positive result result. So I, as a reader, am not so concerned about version issues.

    Also, it's worth noting that animating the alpha channel(and I think all colors too) on legacy animations is currently broken. It's very highly voted in the tracker section of the website, so it should be fixed soon, but it might be worth mentioning if you cover the subject in your new book.
     
  34. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    Hi Gaugeforever,

    I already had the idea to see about hooking you guys up with the new book in some way- will work on that. Please PM me if you are interested. It is more first person shooter, but covers some of the same stuff, especially how everything works together. Also, it uses C#.

    As soon as I get the new book finished (doing a second pass on the last chapter now), I want to start working through the Beginning book again so I can get you guys a comprehensive list of errors, and better explanations where needed.

    And yes, unfortunately I think I was the only one working through the project (a couple of passes), but in making things work, being human, I occasionally forgot to change the text in the book (we won't even go into the logistics of discovering a little issue in chapter, say, 14 that requires changes that trickle back all the way to chapter 7 after they've been turned in...)

    re publish on new book, it may make it out this month, but the timing is a bit tight, so no promises

    re material opacity, yeah, that was a stupid thing to break and leave broken for so long...

    and I want to say thanks for everyone's feedback - even the not so good stuff- it helps me make things better for you and me

    Sue
     
  35. Gaugeforever

    Gaugeforever

    Joined:
    Mar 12, 2014
    Posts:
    9
    Heh just checked the tracker and there was a dev response that said they are not going to fix the legacy animator anymore. animating alpha channel on legacy animations will not be fixed :'(
     
  36. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    We'll just have to use Mecanim
    they've made some improvements so it's not as clodgy to use for non-character stuff
    I'll do a quick video on it as soon as 4.5 is released

    Sue
     
  37. Jat_B

    Jat_B

    Joined:
    Apr 12, 2014
    Posts:
    1
    Any chance someone could be awesome enough to throw up the State management PDF on a file sharing site, or email it to me. I am currently guessing the elements, which makes life more interesting (Object Name - Element 1 - Flower needing lots of TLC. Element 2 - Flower has too much TLC), but would like it to be accurate :)

    Cheers!

    Edit: Never mind, I found it. For those who don't have it, its because there are 2 editions on the apress website. Make sure you grab the 2nd edition one here http://www.apress.com/9781430234227 (I grabbed the 1st edition one accidentally). If you don't fancy the 2GB download, PM me with your email, and I will send over the PDF).
     
    Last edited: Apr 12, 2014
  38. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Hi Sue

    I'm on page 606 and have added the capsule colliders and rigid bodies to the characters. However, now when I play the scene the characters fall through the plane. If I remove the rigid body they stay on the plane but walk through the cube, which they are meant to fall over. If I uncheck Use Gravity the characters step up onto the cube but keep on going up! What is going wrong?
     
  39. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    are the capsule colliders safely above the plane when you click play?
     
  40. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Yes. Even if I move the character well above the plane, it still falls through.

    It's ok Sue, I've sorted it - The characters were below the plane! However, I don't understand why they didn't fall through the scene when without rigid bodies I clicked play
     
    Last edited: Apr 14, 2014
  41. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    rigidbodies are where the gravity comes from
    on first person controllers, the rigidbody stuff is built into the Character Controller component
    anything else must have a rigidbody to 'fall'
    colliders will stop a rigidbody, but that's about all they do besides define a boundary for an object

    glad the mystery is solved!

    Sue
     
  42. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Hi

    Page 628 Allowing for Conversation; how do I select a character to start a conversation when there is no cursor?

    Page 634 Adding the NPCs to the Game;I have completed the code for this section. Now, when I run the program I get a Null Reference Exception error message thrown by the line "character [currentNpc].GetComponent (Interactor).processing = false;" in the DialogueManager script. This happens on exit from the conversation.
    The currentNpc is set to 2, but instead of picking up the "Kahmi Prefab" object it is selecting "Kahmi", which doesn't have an Interactor script assigned to it. Could that be causing the error?
     
    Last edited: Apr 20, 2014
  43. GameTech

    GameTech

    Joined:
    Dec 26, 2012
    Posts:
    53
    Hi Sue,

    I've recognized the errors in the book, but managed to work through them to have a workable game. I wanted to know whether the game assets I downloaded for the book project and the code used from the book are usable in a commercial game? Like could I use them as if they were free assets from the Unity asset store?
     
    Last edited: Apr 20, 2014
  44. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    @ GameTech- yes, you may treat them as free assets, free to use, but not to redistribute or sell. Glad you were able to work through!

    @ Tony- for conversation, in the game your cursor should appear any time you are not moving. In the test scene it should not be suppressed. Does it happen in maximized?
    Re Kahmi- will need to look closer at that, but definitely a good thing to investigate first.
     
  45. Ebkac

    Ebkac

    Joined:
    Feb 3, 2012
    Posts:
    62
    Sue, your original version of this book was the first Unity book I purchased, long time ago. I have not seen this newest version but just wanted to say thanks for your work on all the versions. /cheers
     
  46. tholland

    tholland

    Joined:
    May 28, 2009
    Posts:
    129
    Thanks Sue. I am a littler confused by the references to "Kahmi Prefab" and "the Kahmi prefab" on page 633. Are they the same thing? Also, item 9 at the bottom of page 635 refers to "newer objects"; what are these?
     
  47. GameTech

    GameTech

    Joined:
    Dec 26, 2012
    Posts:
    53
    @3DJunkie thanks so much! So the newer books focus on FPS and uses C#? I actually wrote FPS controls using C# and I didn't realized that javascript (the beginning unity book uses javascript) and C# can't actually access each other cause one compiles before the other? I managed to get them to work together, but using inefficient methods. I am making a FPS survival horror adventure game so if the newer books works on both I might check it out.
     
  48. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    @Tony, I looked at my chapter 16 project and the prefab's name is Kahmi, (as is the child root motion object, unfortunately), so it should always read 'the Kahmi prefab'. I think at one time I had the prefab named Kahmi Prefab because of the ambiguity, but changed it
    No idea about the "newer objects"- what chapter and how many pages in? (my version only has per chapter pages)


    @GameTech- When using JavaScript and C# together, you have to make sure the one being accessed exists before the one accessing it can call it. So you would put it in the Standard Assets folder, or a folder named Plugins. Both of those are compiled first. In this version of the book, because of the mobile restrictions, I tried to make the code comply to the type restrictions (no JavaScript dynamically typed arrays, no multi-dimensional arrays) so you shouldn't have too much trouble converting JavaScript to C# or C# to JavaScript). I will probably convert it to C# for the next version and may try to do that when I work through the book again (starting next week, hopefully). Feel free to post code that has you stumped we can have a look at it.
    'survival horror adventure game' sounds creepy :)

    Sue
     
  49. GameTech

    GameTech

    Joined:
    Dec 26, 2012
    Posts:
    53
    I can't for the life of me find out why camera match always ends with the camera view in a different rotation. This is the script to get the player's camera in a position to view an animation. I want the camera view to not move after it ends, it basically shifts rotation weirdly. Here is part of the code it is kind of long. I commented out the navigation parts because I added in different controls.

    Code (csharp):
    1. function Update () {
    2.     if (!matching) return;
    3.     if (matching  !dMode) {
    4.         dMode = true;
    5.         fPController.GetComponent(CharacterMotor).enabled = false; // turn off navigation
    6.         fPController.GetComponent(FPAdventurerInputController).enabled = false; // turn off navigation
    7.         fPController.GetComponent(MouseLookRestricted).enabled = false; // turn off navigation
    8.         fPCamera.GetComponent(MouseLookRestricted).enabled = false;
    9.         SendMessage("Movement",2);
    10.     }
    11.     if (Time.time < endTime) {
    12.         // Do movement
    13.         var t = (Time.time - endTime + matchTime) / matchTime; // Goes from 0 to 1
    14.         WaveLike(t,9); // make movement start and end slower - ease-in/ease-out
    15.         var toPos = Vector3(targetPos.position.x,source.y,targetPos.position.z);
    16.         transform.position = Vector3.Lerp(source,toPos,t);
    17.         // Do rotation
    18.         if (isLookAtSmooth) {
    19.             // Separate horizontal  vertical movement, apply to player  cam objects, respectively
    20.             // Horizontal
    21.             var playerAngle = Mathf.Atan2(targetLook.position.x - transform.position.x, targetLook.position.z - transform.position.z) * Mathf.Rad2Deg;
    22.             var playerRot = Quaternion.AngleAxis(playerAngle,Vector3.up);
    23.             transform.rotation = Quaternion.Slerp(transform.rotation,playerRot,t);
    24.             // Vertical, rotate camera towards target
    25.             var targetPoint = targetLook.position;
    26.             var targetRotation = Quaternion.LookRotation(targetPoint - fPCamera.transform.position,Vector3.up);
    27.             // get distance away from target so you can adjust speed of match
    28.             var dist = Vector3.Distance(targetPos.position,transform.position);
    29.             fPCamera.transform.rotation = Quaternion.Slerp(fPCamera.transform.rotation,targetRotation,Time.deltaTime * (10 - dist));
    30.         } // close isLookAtSmooth
    31.         justMatched = true;
    32.         // Disable player navigation input while this script controls player position
    33.         Input.ResetInputAxes();
    34.     } // close the original conditional
    35.     else {
    36.         if (justMatched) {
    37.             // Keep player input disabled
    38.             Input.ResetInputAxes();
    39.             // report the new rotation back to the mouselook script - very important!
    40.    
    41.             camMouseScript.ResetRotationY(-1 * fPCamera.transform.rotation.eulerAngles.x);
    42.    
    43.             toPos = Vector3(targetPos.position.x,source.y,targetPos.position.z);
    44.             transform.position = toPos;
    45.             justMatched = false;
    46.         }
    47.         if (Time.time < (endTime + animationTime)) { // if there are other animations to watch
    48.             // Keep player input disabled
    49.             Input.ResetInputAxes();
    50.             //fPCamera.transform.LookAt(targetLook);   
    51.         }
    52.         else {
    53.             // Done with match. Reset for next time
    54.             matching = false;
    55.             // enable mouse again
    56.             Screen.lockCursor = false;
    57.             // flag for cursor visibility and mouse functions
    58.             gameObject.Find("Control Center").GetComponent(GameManager).camMatch = false;
    59.             /*
    60.             fPController.GetComponent(CharacterMotor).enabled = true; // turn on navigation
    61.             fPController.GetComponent(FPAdventurerInputController).enabled = true; // turn on navigation
    62.             fPController.GetComponent(MouseLookRestricted).enabled = true; // turn on navigation
    63.             fPCamera.GetComponent(MouseLookRestricted).enabled = true;
    64.             */
    65.             SendMessage("Movement",1);
    66.             dMode = false;
    67.            
    68.         }
    69.     } // end else
    70. } // end update function
     
  50. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    hi GameTech,

    is your look-at target object parented to another object?
    are the numbers matching up from when the fpc is in place and looking at the target??
    have it print out the fpc camera numbers as it matches