Search Unity

Beginning 3D Game Development with Unity 4

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

  1. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    Ok, here is a little test script to put the image at hte cursor position and change the color on the Raw Image component (toggles with the space bar)

    add this script to an object with a RawImage

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var rawImage : UI.RawImage;
    4.  
    5. function Start () {
    6.     rawImage = GetComponent(UI.RawImage);
    7. }
    8.  
    9. function Update () {
    10.     // gets the current cursor position as a vetor2 type variable
    11.     var pos = Input.mousePosition;
    12.  
    13.     // feed its x and y positions back into the  object's transform
    14.    transform.position.x = pos.x;
    15.   transform.position.y = pos.y;
    16.  
    17.   // toggle color change with spacebar
    18.   if(Input.GetButtonDown("Jump")) {
    19.       if( rawImage.color == Color.green) {
    20.           rawImage.color = Color.white;
    21.       }
    22.       else rawImage.color = Color.green;
    23.     }
    24. }
     
  2. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    for the offset of the image, In the Rect Transform, set the Pivot X to 0 and Y to 1

    right, and the size of the image is set in Width and Height
     
  3. Ijisthee

    Ijisthee

    Joined:
    Aug 30, 2014
    Posts:
    12
    This works properly!
     
  4. Ijisthee

    Ijisthee

    Joined:
    Aug 30, 2014
    Posts:
    12
    Don't know if its related to unity 4.6 but on page 206 3. In the Start function, assign the default cursor as the current cursor: [...]

    it doesn't work with the Start function. It only works with the Awake function. Don't know why, but it's 100% reproducible.

    Hope it helps. :)


    edit: embarrassing.... I called the Start function "function start ()" instead of "function Start ()" :oops:
     
    Last edited: Aug 31, 2014
  5. Ijisthee

    Ijisthee

    Joined:
    Aug 30, 2014
    Posts:
    12
    hmm... Page 279 Using Unitys Animation View is outdatet.

    http://docs.unity3d.com/Manual/AnimatorCurves.html (seems to be PRO ONLY now)

    here you can see what I mean:



    MY QUESTION: Is there a workaround for NON-PRO-USERS?
    I didn't find something nice.
    I could deactivate the mesh renderer "enabled" via animation. But thats not fade out... just a "disappear".

    Ok... for non-pro-users its the "fade out - light version" :confused:
     
    Last edited: Aug 31, 2014
  6. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    The only way to animate the opacity of a material now is to use the Animator component instead of an Animation component. The Mecanim curves are not related to this.

    remove the key from the group with the Animation component on it
    add an Animator component to the key
    open the Animation view
    turn on the red record button
    move the time indicator to 60 frames/1 second
    in the inspector, set the material's opacity to 0

    there's more to trigger the animation, but fading a material is not pro-only
    <sigh> I need to make a video for the key fade when I've got time
    (making video = fast, getting U-tube account set up = slow)
     
  7. Ijisthee

    Ijisthee

    Joined:
    Aug 30, 2014
    Posts:
    12
    Thanks, I can wait.

    Love your very tender support! :)
     
  8. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Hi, i really love your book , :)

    I at chapter 4, i have import the ExtraTerrainAssets folder, i was able to create the prefabbed version of the Banyan tree with the capsule collider, but when i paint it and play the scene, he don't move with the wind like the other tree, do its because i didint find the option "Refresh Tree and Detail Prototypes" ?

    I have Unity version 4.5.0f.6

    Thank you !
     
  9. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    do you have a wind Zone object in the scene?
    did you set a value for the Bend on the Banyan tree?
     
  10. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    @3D Junkie
    Thank you, that was the Bend value..:)

    Thank !!:p
     
  11. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Hi,did you find a way to make to rock animate again?

    I stuck at page 338 right now ,same problem as you!
     
  12. k1mset

    k1mset

    Joined:
    Dec 4, 2012
    Posts:
    64
    I was doing that page last night, the issue is somewhere in the coding I think. Using the code I made in the book, the result would come as you say, you pick the object, hear the noise, your print function goes, but no animation at all with the Flower, or the Rock. However, I imported the Chapter 9 script for the Interactor, and loaded that in with all the settings, and it worked fine. So I think maybe the books script is bugged.
     
  13. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Thank i will try that!
     
  14. Pecebaby

    Pecebaby

    Joined:
    Aug 3, 2013
    Posts:
    11
    I'm having trouble with downloading the assets package, I was wondering if there was a more effective way to link up the download url... or something, The issue I keep having is that the download is so huge that EVERY time i try to download it something happens to corrupt / inturrupt the download. I find that torrents can be an effective method, at least for those who are having the same issue I am. (It will pause if the internet connection is dropped instead of just corrupting the DL)

    I would Like to mention, Sue... I think your book is GREAT, I haven't been usung unity long... I also have very little C# expience... at least before I started this book... and even with your focus in Java I've been able to progress leaps and bounds thanks to your help.

    Also, I really would like to mention that I really appreciate your book because I'm able to do a lot of the work offline while I'm not at home... (my workplace has no internet, and I work in a seasonal boarding type situation). Most material I find these days is online, on youtube, so I can't take lessons with me when I go. Also a lot of material I find can be unclear, confusing, or missing minor to large details that can make or break the lesson... I find you have a very clear, professional, and thorough method of teaching.

    Thank You soooooo much for all your hard work.

    Jesse
     
  15. Pecebaby

    Pecebaby

    Joined:
    Aug 3, 2013
    Posts:
    11
    I'm using unity 5 now, and the fade does not work for me, I tried switching to transparent shaders, (in the legacy menu ((which was a bit harder to find, since its different from the book))) no results. I'm noticing that the materials are listed differently from the way they were in unity 4, I have to use the mesh renderer, material color. It seems like each time i change a value by its number, the other key changes back to the same number... the curve however looks correct to me.
     
  16. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    Are you using the Animator or Animation component? The legacy Animation no longer supports animated opacity. You must use Mecanim (so you will have an Animator component). It's a lot more work to set up, but should work. PM me if you are still having trouble (they keep making changes...).

    Sue
     
  17. Pecebaby

    Pecebaby

    Joined:
    Aug 3, 2013
    Posts:
    11
    Thanks sue, but yeah, I actually moved beyond the fade step, and simply replaced it with "object active" in the animation window, so that it simply disappeared when I was done. I just finally was able to read the last few pages of this thread, and i'll be going through to try out mechanim soon Any way most of that was last week for, so today's issue is in chapter 9.

    In chapter 9 when I implement the interactor script, (after adding the components for audio source and object lookup, things got a little hairy for me. At first I realized I had deleted the rock and key from the animations object in the hierarchy, so I had some work to do reverting the rock back to it's original state. Somehow along the way (in the process of F***ing with animations to make fade work) I managed to also make it so that my animation "rock move" was playing in the old "rock groups" location rather than where the newly repaired rock was located... anyway i solved all that and was able to get the rock to move, play its sound, and change state appropriately. However now that I'm looking at the "Lock Plate", it refuses to play it's audio. If I'm not mistaken it should play SOME (one of three) audio, regardless of what state it is in and going into, and everything appears to be set in the arrays... Also the audio source is present.

    This is all right before you beging working on the looping animation.
     
  18. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    test #1- set the audio component's Volume Rolloff to Linear, set it to Play on Awake & drop an audio clip in there to make sure everything in the component is working

    if the other objects work, this is sharing the same code, so it shouldn't be a code problem

    because the LockPlate is not much more than a collider sitting on the trunk base, it may not be receiving its pick so you might put a print statement into the OnMouseDown function & have it tell the name of the object

    can't think of anything else to try just now
     
  19. Pecebaby

    Pecebaby

    Joined:
    Aug 3, 2013
    Posts:
    11
    thanks, ill go back and try to solve it soon, but I'm thinking either I set something wrong somewhere or my code was faulty,,, I simply replaced my script with a copy from finished ch 9 and replaced all the old components with new ones,,, something along the way fixed it... for now I'm going to move onto ch10

    thanks for the speedy reply, and I really love the book it's been super helpful.
     
  20. Pecebaby

    Pecebaby

    Joined:
    Aug 3, 2013
    Posts:
    11

    Lol at this point things are getting progessivly more difficult to troubleshoot on my own, and it feels like I'm bumping into these road blocks more frequently as I go. Now for some reason, Right as we get started off, I'm trying to hook up the auxilury objects to the interactor. I have everything set up correctly (I think) but when I click the rock hoping it will transition the pedestal to state 2 the console gives me a message of new state, but the values in the inspector don't change.
    I am thinking that maybe this is the way it should be for some reason... so I'm going to move onto the flower now and see where it goes from there... but I am willing to bet I'll be back here soon hoping for a fix lol
     
  21. Pecebaby

    Pecebaby

    Joined:
    Aug 3, 2013
    Posts:
    11
    I discovered that the flower>rock>pedestal in my scene do not work appropriatly either, suggesting that I got the code in the Object Lookup or Interactor wrong. I must admit that I have a hard time knowing where exactly I am supposed to be putting certain additions to certain scripts. (suggesting that I need to refine my understanding of what each function is doing and how the scripting actually works)
     
  22. Pecebaby

    Pecebaby

    Joined:
    Aug 3, 2013
    Posts:
    11
    Finally I fixed it, I think it was one of the look up states numbered wrong on the pedestal, either that or I had a simple line of code out of order (in the correct block)... After a few hours of trial and error, it finally works again and I'm back on the road. Not sure which solved it because I changed both before I realized it was working.
     
  23. Pecebaby

    Pecebaby

    Joined:
    Aug 3, 2013
    Posts:
    11
    For starters, Sue,
    I wanted to thank you for,... after several years, still keeping up with the readers of you're book. I have to admit that I didn't expect you still be actively monitoring your thread here. That being said, I've (as uve seen already) bumped into multiple issues, some large some small. I DON'T blame you by any means... Realistically I credit most of my issues to my own human error and many of the other issues to the changes made to unity since you wrote these books.

    Anyway, you've helped me to move onto other parts of the book when I was stuck. In a lot of cases when I have an issue I tend to dwell on it, and waste a lot of time trouble shooting... However at the same time I often find that by simply progressing further in the book I often come across a solution later on. I often fear that if I simply skip a section I will bump into an issue related to the fact that I didn't solve a problem earlier on. This, (in most cases) is avoided by simply loading the finished version of your project, but I can't help but assume that this is a bad way to learn. Being as that this is simply a hobby of mine, it is extremely important to me to learn and absorb as much as I possibly can.

    SO, as I progress, I am currently in chapter 10, "Handling Visibility" and I have run into an issue that I am concerned has already been solved and explained to me, but I am just not sure. I understand that we have established that the animation window no longer functions as it used to, but for some reason I had assumed that handling the visibility in code would not correlate to the animation portion of this function... I am wondering if I should:
    A) trouble shoot my issue where I stand (because it may or may not be related to changes in unity 5
    B)skip the handling visibility section and return to it later when I delve into the machanim solution you've presented here on the forums or
    C) Delve into the mechanim immediately in order to grasp a better understanding of what is causing my issue (meaning that my issue IS related to the changes made in animation and mechanim((or possibly not I suppose))).

    In the mean time I hate to simply sit around and wait for a response, so I think I will begin playing with the mechanim fix you've presented us or simply move on to the next part of the book (because I simply can't wait to progress further)

    Again, my compliments on a fantastic book. I Have read a few post from not so happy readers, but I think there disappointment tends to be misplaced... I find that it is really easy to misinterpret certain directions when they are not quite visual. (when working with a highly visual medium) From my perspective you've helped me to progress in unexplicable ways.

    One gigantic factor in my opinion is the fact that I started you're book about 2 years ago now, and made it to about chaprter 8 (just before my current place in your book) without the asset download included with it. (I was trying to complete you're book while I had no internet at my residence) After taking almost a year off from working on it, I came back to find that when I started the book over I was WAY WAY WAY more informed and comfortable about progressing through you're lessons. Being that I was in unity 4 when I started it I bumped into significantly less issues based on program changes and updated content, and significantly more issues revolving around my own human error and uninformed ignorance.

    Before I jumped back into you're book for a second time I went through and completed a basic 2D RPG tutorial on youtube, the Space Shooter Tut here on unity, and I also started the the survival shooter on unity but never finished it (YET). These simple tutorials were made significantly easier with the knowledge I was equipped with after attempting you book the first time... However, at the same time you're first few chapters were also made significantly easier to repeat after learning some other bits and pieces from other sources.

    I am excited to see everything converted to C# and I hope that, that is still a project in your peripherals... I know you said you got wrapped up in another project... But I have noticed a large shift in the use of Java into C#. Even if this is not a future project for you still, I've noticed some fans doing the work for you and I can't wait to communicate with them about the changes.

    All-in-All
    I really wanted to thank you for such a great platform to stand on when getting stated in any form of programming. It can be extremely overwhelming to get a start in this type of medium so it's really refreshing to be offered a source of info that is not quite as scary and intimidating as some of the other materials I've encountered in the past (MOST)

    -Jesse
    -AKA Peacebaby
    -AKA EchoDev
     
  24. shiraz latif

    shiraz latif

    Joined:
    Sep 9, 2015
    Posts:
    1
    I am following the same book the book is very effective and easy to understand
    i have a problem of assets i downloaded the book from torrent but it doesn't contain the assets folder in it so where do i get assets please help me.