Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 3 Video Training Course (FREE) - Walker Boys

Discussion in 'Community Learning & Teaching' started by profcwalker, Dec 8, 2010.

  1. Kanly

    Kanly

    Joined:
    Feb 8, 2011
    Posts:
    87
    if you are using transform.position to move the cube around the scene, you might want to check out transform.Translate...
     
  2. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    missy_pooh. I haven't worked with the speech-recognition, so I wouldn't be able to comment properly toward it. You may want to post the question in the forums to see if anyone has used them.

    Jay_Santos. I got the email with the link to the lab. We'll take a look at it soon. Thank you.

    clip911. It's good to see you working through your ideas on the movement. Remember, when learning programming for the first time, your approach and the steps to get there are the important thing to work through on your own. I remember when I first learned to program (Only having a little bit of logic to pull from), it was problems like these, that caused me to think and work on it for hours....sometimes days. As you begin to get a foundation in logical problem solving, you'll find the answers start coming much easier. :) Best of luck with it. If you get completely stuck and it's the end of the week, just let me know.

    Thank you
     
  3. insomniacl

    insomniacl

    Joined:
    May 12, 2011
    Posts:
    14
    Question for a Walker bro, or anyone whose done the Mario 2D lab.

    Regarding tutorial 8, camera with border follow script. We basically have something like this:
    Now, I understand we're re-adjusting the camera's position to "camera.transform.position.x + borderX". But I don't understand the math involved. Using print(camera.transform.position.x), you can basically see that the camera starts at about x = -4.0. Thus, camera.transform.position.x + borderX = -4 + 2 = -2. Past this point is when mario triggers the camera to move. So far so good, so assuming mario is now moving past x=-2, execute the camera move.

    Now we must move the camera FROM x=-4 TO (camera.transform.position.x + borderX), which is -2 as previously established. However, when the code actually executes, the camera ends up at x = 0, not x = -2. Whats going on here? Why is the camera moving by 4, and not 2?
     
  4. dilly123

    dilly123

    Joined:
    Nov 1, 2009
    Posts:
    23
    Wow, Very good of tutorials. Thanks!
     
  5. satan

    satan

    Joined:
    Jan 17, 2010
    Posts:
    13
    Can anybody tell me , how long does it take to get your lab checked? I've emailed aproximately 4 days ago... can't wait to move forward :)
     
  6. missy_pooh

    missy_pooh

    Joined:
    Jun 1, 2011
    Posts:
    150
    missy_pooh. I haven't worked with the speech-recognition, so I wouldn't be able to comment properly toward it. You may want to post the question in the forums to see if anyone has used them.

    @ProfCWalker: : Thank you for replying. I assume that you know Unity very well, do you think that it's possible to add this kind of function into Unity??

    Just to add on more, my project require me to create an educational game to teach chinese. This is why i would like to add on the voice recognition part as advanced feature. I would like to ask beside the voice recognition part, what else can be added to the game so that it would increase the standard of the project. Another ideas is that i am thinking whether Unity support database? Like for example, we can store student's particular and also to keep track of student's record,like which word they are weak at so that the teacher could keep track of it. I would appreciate for some suggestions/advice. Thank you very much :)
     
  7. nopcode

    nopcode

    Joined:
    Apr 29, 2011
    Posts:
    67
    Passwords? Really?
     
  8. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    Apparently, yes... really.

    They are pretty good at it. I don't know if they check over the week ends but I got mine pretty much monday afternoon ish.

    Jay Santos, if you still need a page thing, you can just use google to do it.

    http://sites.google.com/
     
    Last edited: Jun 7, 2011
  9. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
    Thanks pothb, but I've managed to (barely) post my lab to 000webhost

    I've tried google sites, but not deep enough. Can I embed my unity game to a google page?

    Once again thanks for your help.
     
  10. Cusco

    Cusco

    Joined:
    May 24, 2011
    Posts:
    43
    @Jay try this in Wordpress? Unity Webplayer Wordpress plug-in

    It working very well with my site =D http://unitylab.webxway.com/
     
  11. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
    @Cusco, you're using 000webhost as well, right?

    Something's wrong with my site... I tried using their website builder, got an error and now if I try to use the wordpress tool I get a "No valid license!" error

    My page's not as polished as yours, but at least I managed to post the lab... Have a look http://www.jayunity.netii.net/WalkerBoysLab01_web.html
     
  12. Cusco

    Cusco

    Joined:
    May 24, 2011
    Posts:
    43
    I can't Open your website ... sorry... yr website same like have some problem?

    *******************************************
    This web page has been blocked by BitDefender Antivirus Real-time Protection!

    The web page blocked by BitDefender included objects that were either infected or likely to be infected with a virus. Your system has NOT been infected.
    *******************************************

    I am not using 000webhost, but just install the wordpress and the Unity Webplayer plus-in that would be work @@
     
    Last edited: Jun 9, 2011
  13. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
    @Cusco But you're not using google pages either, right?

    @ProfCWalker Can you check if you can open the page? I've sent the link to a friend of mine and he had no problems, but now I'm concerned, and I want to get to Lab 3 ASAP :)

    Thanks guys
     
  14. stefek99

    stefek99

    Joined:
    May 27, 2011
    Posts:
    6
    I was searching for the same file but "the text isn’t actually available, but feel free to copy it from the video." :(

    Maybe you can enable download of certain files / add this to video description, here: http://vimeo.com/album/1512103/video/18905653 ?

    In fact you can go full screen and see what is written on the screen :)
     
    Last edited: Jun 9, 2011
  15. Stec

    Stec

    Joined:
    Apr 13, 2011
    Posts:
    118
    @insomniacl

    In the first if statement we are checking the position.x of camera.Targer (playerFocus) and if it is greater then camera.position.x + borderX (the default is 2) then enable moveScreenRight. Now, Since the Mathf.SmoothDamp is located in the Update function the arguments for that will change constantly. Lets look at the first two arguments, they are : camera.transform.position.x (current : float) and camera.transform.position.x + borderX (targer : float) the SmoothDamp will change a value from current to target depending on the smoothTime. But since we are in the Update function the SmoothDamp will calculate a number to infinity, becouse the camera.position.x is changes every frame and that new position is an argument for the SmoothDamp so that the function will never reach the target.
    For that reason we have this piece of code:
    Code (csharp):
    1.  
    2. if ( cameraTarget.transform.position.x < camera.transform.position.x - borderX  moveDir.moveDirection == 1)                
    3.     {
    4.         moveScreenRight = false;
    5.     }
    6.  
    I hope that this is now more clearer to you
     
  16. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    JaySantos, It seems fine, it opens for me.

    Your first project is way better than mine. LOL, mine kind of sucked...
     
    Last edited: Jun 10, 2011
  17. Cusco

    Cusco

    Joined:
    May 24, 2011
    Posts:
    43
    "camera.transform.position.x + borderX, velocity.y, smoothTime);" will it because of yr wrong "velocity.y" but not "velocity.x" @@?
     
  18. bryanleister

    bryanleister

    Joined:
    Apr 28, 2009
    Posts:
    130
    Awesome series, thanks for providing this.

    I have a couple of questions about general game logic/practices:

    1. Often you are declaring variables in the update loop, how do you decide when to do this and why? As a rule, I've been avoiding doing that because I felt it would be bad for performance.

    2. How do you make decisions about what objects get certain functions applied to them? I'm Thinking of Lab 2 and the explosions, scores,etc. Many of those could be on any object, what are the principles you are thinking of when deciding which object to place them on?

    Occasionally you explain as you are showing, but it's always helpful to get a feel for why you are doing things a certain way.

    Thanks!
     
  19. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    Here's my opinion on them, if you want em.

    1. When you declare a variable in the loop, it is redeclared every time, and I can't remember for sure if the professors do it, but I usually do, and is reassigned a value. So it will always start with that value. Like when you do a loop to go through all the enemies on the scene, you'll always want it to start at one, and it will increment to the max. Next time it loops, you want to make sure it's back to 1 and going through again, rather than starting at the max and then going out of bounds.

    Basically something that will only affect what's there and will not be needed to be carried through, like a score.

    I'm not sure what you mean with question 2. But it sounds like, when do you make a function? If so, for me, I make functions when I see repeating code. Though the professor don't seem to do this, I like to keep my update fairly short. So if something happens, like an if then statement, I usually make a function for it and have my update use "function()" to keep it short.
     
  20. Cusco

    Cusco

    Joined:
    May 24, 2011
    Posts:
    43
    1. Are you talking about the gameloop define?
    Update() I think is same like AS3 OnEnterFrame(), but u still can keep the program structured as MVC. ie. Input -> Logic -> Render. Please read "Update Order" section?
    http://unity3d.com/support/documentation/Manual/Execution%20Order.html

    2. How do you make decisions about what objects get certain functions applied to them?
    - 1) Drag Drop the script on the GameObject to apply the function on targeted object
    - 2) To get a script to current script - use GetComponent to have a instance
    - 3) To get a script from another object use GameObject.Find or GameObject.FindWithTag or GameObject.FindGameObjectsWithTag
     
    Last edited: Jun 11, 2011
  21. Stolenbows

    Stolenbows

    Joined:
    Nov 30, 2010
    Posts:
    82
    this is greatly done! taking those exams is very helpful
     
  22. Stolenbows

    Stolenbows

    Joined:
    Nov 30, 2010
    Posts:
    82
    ah damn! 7th time i try the first exam every time below the score needed usefull tho
     
  23. bryanleister

    bryanleister

    Joined:
    Apr 28, 2009
    Posts:
    130
    I guess I was not being entirely clear. I've seen a number of discussions on declaring variables inside loops:

    http://forum.unity3d.com/threads/58197-Declaring-variables-and-loop

    On a function that is only called on an event, I don't see a potential performance problem declaring the variable within the loop. But, as Update() is called once per frame, wouldn't this:

    Code (csharp):
    1.  
    2.  
    3. private var transV : float;
    4. private var transH : float;
    5.  
    6. function Update ()
    7. {
    8.     //Store input variable
    9.     transV = Input.GetAxis("Vertical")* playerSpeedVertical * Time.deltaTime;
    10.     transH = Input.GetAxis("Horizontal")* playerSpeedHorizontal * Time.deltaTime;
    11.    
    12.     //Move player based on Input
    13.     transform.Translate(transH, transV,0);
    14.  
    be faster than this:

    Code (csharp):
    1.  
    2.  
    3. function Update ()
    4. {
    5.     //Store input variable
    6.     var transV : float = Input.GetAxis("Vertical")* playerSpeedVertical * Time.deltaTime;
    7.     var transH : float = Input.GetAxis("Horizontal")* playerSpeedHorizontal * Time.deltaTime;
    8.    
    9.     //Move player based on Input
    10.     transform.Translate(transH, transV,0);
    11.  
    (This is for the Lab 2 project, asteroid shooter.)

    I actually have a feeling it is not faster, but wanted to hear why as I would like to know the logic behind choosing to declare inside the Update() function on some things, but not others.

    I absolutely love how organized the projects are that the Walker boys are doing. It's great to see how the same basic setup can apply to multiple games and it really feels like a professionally crafted game design process. So, my second question was simply about how to decide where to put different scripts snippets.

    For example, the explosion sound could be on the bullet or the object being hit. I would put the sound on the object being hit, since it is what is exploding, but the WB put the sounds on the bullets. They then had to write a script to create a sound instance since the bullet is being destroyed.

    The second is the player score and lives. This could be on the player, but it is on the sceneManager in the case of score and lives are on the player. When I do my game, I would like to stay organized and so wanted to know if there is a test for what items get put onto what objects.
     
  24. Thiago6891

    Thiago6891

    Joined:
    Jun 8, 2011
    Posts:
    22
    @bryanleister

    1 - I think as a programmer you should think about the pros and cons. If you declare it inside the update method, you sacrifice performance and make your program smaller. If you declare it outside, it will make your program bigger but favor performance. I like to favor performance and avoid declaring variables inside the update method (or any other frequently called function), but depending on your target machine and the amount of declarations, I don't think it has a noticeable impact on performance.

    2 - That's a design decision imo. Just put it wherever you think it fits better, I usually like to put general scripts (or other components) in the main camera, but you could create an empty game object to put them in.
     
  25. Cusco

    Cusco

    Joined:
    May 24, 2011
    Posts:
    43
    @bryanleister

    I think Unity JavaScript and common JavaScript is different ... for me ... especially dunno how to declaring class in Unity too - LOL

    but every var outside of function call it will declaring variables as Global variable (which will holding in memory) and it will allocate memory until yr program stop

    if you declaring variables inside function, after Update run, the inside function as Local variable will be free up the memory
     
    Last edited: Jun 11, 2011
  26. Kanly

    Kanly

    Joined:
    Feb 8, 2011
    Posts:
    87
    that's why you'll find that Unity JavaScript is informally named UnityScript, it really isn't javascript at all, but a lot of people know JavaScript and they know it's easy to learn... it's UT's dirty little secret.
     
  27. Maxwell Edison

    Maxwell Edison

    Joined:
    Jun 12, 2011
    Posts:
    1
    Unity app 1 19 to 29 are missing. Probably the videos that deal with component.
    Could the walker boys please re-up them.
     
  28. clip911

    clip911

    Joined:
    May 21, 2011
    Posts:
    31
    :( 3absiso its still not working.
    man i m Stuck now.
     
  29. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    @bryanleister


    I think it's done for organization. Where things declared in the loop is only used in that specific loop. Instead of being used by multiple functions or other scripts. Like transV and transH is only used in that loop to control the ship. It won't be used by another function. Where as a bullet variable, private or not might be used by other functions or even other scripts.

    @Maxwell Edison

    They are intentionally left missing. For future uploads.
     
  30. 3absiso

    3absiso

    Joined:
    Apr 16, 2010
    Posts:
    30
    Hay Clip911; can you attach your Code to the moving cube (Both Codes)
    and i may be able to help you
    PEACE
     
  31. mmoDust

    mmoDust

    Joined:
    Jun 13, 2011
    Posts:
    17
    Anyone else run into any abnormal delay getting lab results for the projects? I completed and uploaded lab1 about 3 weeks ago and have not heard anything back yet. Sent 2 emails so far. Maybe it is getting eaten by a spam filter? I use Gmail so i would think it should be fine.

    Any ideas?
     
  32. Thiago6891

    Thiago6891

    Joined:
    Jun 8, 2011
    Posts:
    22
    @mmoDust: Mine didn't take long. They're probably not receiving your e-mails. But I use Gmail as well.
     
  33. mmoDust

    mmoDust

    Joined:
    Jun 13, 2011
    Posts:
    17
    Yeah i do not want to pester them so I am going to just hope for them to notice these posts when they come back and check and can hopefully figure it out from there.

    Started going thru some other tutorials in the meantime to pick up more tricks.
     
  34. chrono1081

    chrono1081

    Joined:
    Nov 15, 2009
    Posts:
    14
    Thank you so much for these tutorials! I haven't used Unity in a long time and these are really helping me get back into the swing of things.
     
  35. kieranbhoy

    kieranbhoy

    Joined:
    May 10, 2011
    Posts:
    189
    How do i start these?
     
  36. Stec

    Stec

    Joined:
    Apr 13, 2011
    Posts:
    118
  37. clip911

    clip911

    Joined:
    May 21, 2011
    Posts:
    31
    LOL , finally i sort out my prob. myself (totally accidental though) . I dunno how u guys do random transformation but it can b done like this also

    transform.position = Vector3(Mathf.PingPong(Time.time * 3 , 9.9) -4.9 , Mathf.PingPong(Time.time * 3, 7.1 )-3.6 ,0 );

    thats it. use pingpong in "z" if u r doing on x z axis. if u use deltaTime the multiply it with big value like 100 or more
     
  38. 3absiso

    3absiso

    Joined:
    Apr 16, 2010
    Posts:
    30
    That is good man;
    it can be easly done with Random.Range
     
  39. Chobi77

    Chobi77

    Joined:
    Jan 20, 2011
    Posts:
    30
    Not sure, i sent them an email long ago asking for help on one of the earlier labs and never got a reply. (i assume it never made it to its destination)

    I finished the third lab a couple of days ago and sent them an email to get my lab results and hopefully move onto mario 2d.

    I haven't had a response yet.

    I hope all is right with the boys and things move along shortly.

    Edit: Just go an email from Eric and i notified him of your problem mmoDust.
     
    Last edited: Jun 15, 2011
  40. Thiago6891

    Thiago6891

    Joined:
    Jun 8, 2011
    Posts:
    22
    It's not really random though.

    Here's how I did it... I randomly choose a new x and y velocity every 5 seconds and used the transform.translate.
    I also check the object's position so it won't move too far away from the screen, you could make it so it won't leave the screen at all.

    Good luck!
     
  41. lorddon

    lorddon

    Joined:
    Jun 16, 2011
    Posts:
    1
    So I'm doing the "On your Own" exercise for Lab 1 and the line of code under the RespawnWaitTime function, transform.position = position, keeps firing before the RespawnWaitTime function finishes executing. This is a problem because it moves the position of the enemyCircle before it has a chance to finish blinking. How do I force that to wait until RespawnWaitTime finishes?

    Thanks,
    Jeremy

    edit: Here's the full Update function:

    Code (csharp):
    1. // Update is called every frame
    2. function Update ()
    3. {
    4.     if(numberOfClicks <= 0)
    5.     {
    6.         if(explosion)
    7.         {
    8.             Instantiate(explosion, transform.position, transform.rotation);     // Create an explosion
    9.         }
    10.         if (audio.clip)
    11.         {
    12.             audio.Play();
    13.         }
    14.         var position = Vector3(Random.Range(-6, 6),Random.Range(-4, 4), 0); // new random position for the game object
    15.         if (enemyShape == "sphere")
    16.         {
    17.             SphereRespawnTime();
    18.         }
    19.         else
    20.         {
    21.             RespawnWaitTime();
    22.         }
    23.         transform.position = position;  // move the game object to the new location
    24.         numberOfClicks = storeClicks;
    25.     }
    26. }
     
    Last edited: Jun 16, 2011
  42. insomniacl

    insomniacl

    Joined:
    May 12, 2011
    Posts:
    14
    @lorddon Try throwing in a yield WaitForSeconds(1); somewhere within your code
     
  43. insomniacl

    insomniacl

    Joined:
    May 12, 2011
    Posts:
    14
    To a Walker or anyone on Lab4:

    Minor issue, but my flag gizmo doesn't seem to show up properly. I've done both loading it into the texture or defaulting to an image if a texture isn't loaded, but I don't see the full image. I just see a tiny white box.

    Any solutions? Thanks
     
  44. beco13

    beco13

    Joined:
    May 31, 2011
    Posts:
    30
    I've just finished uploading my project yesterday but the host admin for my web were maintaining the web yesterday when I tried to access the web, so I didn't post it here yesterday.
    But you guys can access my project now.

    Here's the link :

    http://becounity.webege.com/wordpress/

    A positive comment will serves me better :)

    Hope you guys can comment on my work.

    PS: I'm still very new to programming, please be nice to me :p

    ~ Enrico ~
     
  45. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    Nice. Can't see it not passing.
     
  46. beco13

    beco13

    Joined:
    May 31, 2011
    Posts:
    30
    @pothb : thanks... I can't wait for the next Lab Project...hahaha.... I feel like I'm progressing too slow for this..
     
  47. Red Baron

    Red Baron

    Joined:
    May 27, 2011
    Posts:
    6
    @insomniacl: the Gizmo icons need to reside in the "Assets\Gizmos\" folder. Just create this folder (be sure to name it exactly "Gizmos") at the top level in the project view and put your icons there.
     
  48. kieranbhoy

    kieranbhoy

    Joined:
    May 10, 2011
    Posts:
    189
  49. clip911

    clip911

    Joined:
    May 21, 2011
    Posts:
    31
    thiago : i think i understand what u r saying but i mentioned earlier that i need a transform like ping-pong ball.
    may b i created this confusion coz in 1 quest i asked random.position like movement ping pong in another 1.
    My bad English ;-)

    since i m new in prog. it will take me SOME( lol ) time to develop some nice skills
     
  50. Stec

    Stec

    Joined:
    Apr 13, 2011
    Posts:
    118
    That is your decision, I would suggest that you watch them all, sooner or later you will need something that is coverd in one of the videos. And you will have to take the exams on topics covered in these videos, but you can repeat the exam as many time as you want.