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. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
    OK, Lab 2 question.

    I'm in the shield creation part. I've created the shield and now I am implemeting the collision between shield and asteroid.

    Before I started working with the shield, my Asteroid, Bullet and Player were all triggers, and everything is working.

    When I created the shield also as a trigger and I had a collision between asteroid and shield, only the asteroid script OnTriggerEnter method was called, the OnTriggerEnter method for the shield was not.

    Now, If I set the asteroid as NOT a trigger, everything works fine...

    I tought I had fully understood how triggers worked, but it doesn't seem to be the case... Can anybody clarify that for me?

    Thanks in advance...
     
    Last edited: Jun 17, 2011
  2. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    Hmm, when I wrote my code, all the trigger code was done on one side, rather than both sides. So I never encounter this problem. My guess is that it calls one ontriggerenter then the other, but if the first made one of the objects go away, then there is no reason to call another ontrigger because they are not in position to trigger it.

    EX: asteroid -> shield.
    Shield destroys the asteroid, asteroid is gone, and can't have it's trigger called because it's gone. OR
    Shield is destroyed and asteroid is no longer entering the shield to have it's trigger called.

    Speculations on my part... since I've never encountered it myself though.
     
  3. MITAGAMES

    MITAGAMES

    Joined:
    Jun 1, 2011
    Posts:
    34
    Nice job on the tutorials. Awesome tutorials. Great work!
     
  4. TimHellmann

    TimHellmann

    Joined:
    Mar 6, 2011
    Posts:
    66
    I've got two minor questions for Lab 02.


    First, is there any function or method to stop the player movement when hitting the block, which we should add as a "On your own" task? I already made the asteroids dodging back but the player still walks through the block.


    Second, I got a problem with my "ShieldOn" variable.

    Player Script
    Shield Script

    When the shield turns off (after time or when getting hit), the variable should switch back to FALSE. This is what the function shieldDeactivate() should do. However, the variable is not "false" again in the Update function. The print (shieldOn); in the function says "false" which is correct. If I print the variable in the Update function, it is still "true". So the variable is not switched actually.

    So I can only use the shield once a level because it is "true" as long as the level resets.
     
    Last edited: Jun 18, 2011
  5. Red Baron

    Red Baron

    Joined:
    May 27, 2011
    Posts:
    6
    @AriesT: probably the problem is that shieldDeactivate() is never called on your player. Is player1:Transform in the shield script set to the correct instance of the player?
     
  6. TimHellmann

    TimHellmann

    Joined:
    Mar 6, 2011
    Posts:
    66
    So weit ich weiß, ja.
    As far as I know, yes. ;)

    I linked the prefabPlayer to the Shield script. I was wondering why such external function calls work with the SceneManager. There I do not have any Update function, just OnGui elements but there the Addlife(), AddScore() etc. functions work.

    I changed the script so the shield directly changes the shieldOn variable (without external function). Still does not work.
     
  7. Red Baron

    Red Baron

    Joined:
    May 27, 2011
    Posts:
    6
    So, it is linked with the player object in the Hierarchy view (the instance) and not with a prefab from the Project view?
     
  8. TimHellmann

    TimHellmann

    Joined:
    Mar 6, 2011
    Posts:
    66
    I did it like the Walker Boy tutorials tell me with previous linking.
    The linking works perfectly! The shieldDeactivate function is called. Just the variable in it is not changed.

    I made a player1 : Transform inspector variable and then I put the player prefab on the right spot at the shield prefab. Everything works fine. Beside the variable still stays on "true" even if it should in the function the shield calls in the player script.
     
    Last edited: Jun 18, 2011
  9. Red Baron

    Red Baron

    Joined:
    May 27, 2011
    Posts:
    6
    I have time this evening, if you like you could PM me the whole thing and I'll take a look at it.
     
  10. TimHellmann

    TimHellmann

    Joined:
    Mar 6, 2011
    Posts:
    66
    I won't be at my working computer this evening. I'll send it to you tomorrow morning fi noone else has any thoughts about those two problems. :)
     
  11. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
    That's not the case because the asteroid is not destroyed, I just reset his position to the top of the screen. And I'm only decrementing the shield's life, so it is not destroyed.

    Can you share your trigger config for the objects (player, asteroid, bullet, shield) for lab 2?

    Thanks in advance.
     
  12. BugBr

    BugBr

    Joined:
    Feb 5, 2011
    Posts:
    16
    Lab 2 Question:

    I'm trying to implement random speed for the Astroid, however all Astroids are generated with a same variable speed. I'm avoiding to create two or more different tags for astroids to create different speed, guessing that isn't the best solution. The code I'm using is:

    Code (csharp):
    1. function Update ()
    2. {
    3.     var newSpeed =  asteroidSpeed * Time.deltaTime;
    4.     transform.Translate(Vector3.down * newSpeed * Random.Range(2.0, 4.0));
    5.    
    6.  
    7. //Check for the bottom of the screen
    8. if (transform.position.y <= -8)
    9.     {
    10.     //reset the position of the enemy
    11.     ResetEnemy ();
    12.        
    13.     }
    14. }
    any hints?
    thanks
     
  13. TimHellmann

    TimHellmann

    Joined:
    Mar 6, 2011
    Posts:
    66
    As far as I see, you change the speed every frame in the Update function. Maybe that is the mistake.
    Try this: Randomize / Set the speed once in the ResetEnemy function.

    You do not need multiple tags for that. ;)
     
    Last edited: Jun 18, 2011
  14. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    I would... but my shield is completely different from what the Walker boys did.
     
    Last edited: Jun 18, 2011
  15. 3absiso

    3absiso

    Joined:
    Apr 16, 2010
    Posts:
    30
    First of all putting Random.Range at the update function will update the speed every frame you have to put it out side update function;
    also make the range larger to notice the difference in the speed
     
  16. BugBr

    BugBr

    Joined:
    Feb 5, 2011
    Posts:
    16
    Thank you AriesT!
    I've created a separated function for the random speed and called it on the ResetEnemy function. It worked fine!

    thanks

    Edit:
    indeed 3absiso. I'll work on that!
     
  17. bgm2006

    bgm2006

    Joined:
    Jun 18, 2011
    Posts:
    6
  18. Thiago6891

    Thiago6891

    Joined:
    Jun 8, 2011
    Posts:
    22
    oh ok, I got confused then.:p

    btw, I've finished lab 1 a couple of weeks ago and would like some feedback from the community.
    Here's the link: http://jcgames.netau.net/wordpress
     
  19. clip911

    clip911

    Joined:
    May 21, 2011
    Posts:
    31
    well its 2nd day now n my domain or website is still not activated on 000webhost. so can sme 1 plz tell me how to put the game on google blog
    thiago maybe its my net speed but its showing me the error launching unity player(bad file length)
    can c u r game
     
    Last edited: Jun 20, 2011
  20. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Hi. I am just now getting to the posts. I’ll run through all of them. If I miss something, just let me know.

    Thank you.

    Stec. Thank you for the assist with insomniacl and kieranbhoy. Great job.

    dilly123. Thank you. :)

    missy_pooh. I’ve sent you a pm.

    nopcode. Yes. For the time being.

    pothb. Thank you for the assists, everywhere. It’s much appreciated.

    jay_santos. Just tried the site, everything worked fine. (Used firefox)

    bryanleister. Glad to hear the videos are working for you.
    1. I agree with pothb.
    2. I agree with pothb. Also, it comes down to the size/scope of your project, how many people are working with you, the reusability of it, and the general structure of the files and code.
    One of things we’ve attempted to do, is to grow the code slowly, keep the complexity down to a minimum, and allow for easy readability.

    Cusco. Thank you.

    Stolenbows. Glad the exams are working for you and that you are enjoying them. :)

    Thiago6891. Thank you.

    mmoDust. Did you receive an email yet?

    chrono1081. Happy to help. Thank you.

    insomniacl. Solution: It should be in the Assets\Gizmos\ folder (Red Baron. Thanks.)

    beco13. You’re doing great. :) Remember, when learning something new for the first time, it’s always going to be a bit tough to start with, but it gets easier and better with practice.

    mitagames. Thank you.

    clip911. If you’re still having issues with the site, you can also sign up for a dropbox account (free). Then simply place the html file and unity files on the public folder and generate the public address.


    Thank you all for keeping things going and helping everyone out. We appreciate the time each of you put in to answering the questions and responding to one another.

    Also, thank you for posting your projects on the forum. It’s great to let others see your work, comment on it and get inspired to make one just as good and maybe better. :)

    Thank you!
     
  21. clip911

    clip911

    Joined:
    May 21, 2011
    Posts:
    31
  22. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Just checked and it's working. I've sent you a pm. Thank you.
     
  23. Thiago6891

    Thiago6891

    Joined:
    Jun 8, 2011
    Posts:
    22
    @clip911: Your game is working just fine, loved the particle effects on the blinking sphere:), but I think the moving square was too quick. keep up the good work.:)

    I also got the error when launching the web player of my lab1, sometimes it works, most times it doesn't:(. But there's also a link to download the standalone windows version on the site.
     
  24. clip911

    clip911

    Joined:
    May 21, 2011
    Posts:
    31
    Thiago: thnks man . Well its been like nearly a month that i was working on this project again n again I watched the tuts like 4-5 times, created the project 7-8 times just to understand whats going on, becoz i dont want to be a copycat (atleast not in gaming ), So i just hurried things up here without showing much of creativity, but i m happy that finally i understand what's going on around me. I got my password for 2nd project so i'll be busy again ;-)

    I saw u r game it's working now, u did some nice thing with music with scoring system, points attach with objects. But damn , low down the difficulty level, i cant pass the 3rd level :rolleyes:
     
  25. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
  26. mmoDust

    mmoDust

    Joined:
    Jun 13, 2011
    Posts:
    17

    No response yet and i went thru using the filters in gmail to double check and all i could get back were the 2 emails i sent. Honestly don't know what is going wrong at this point but it is a head scratcher.

    The email address it would have come from would have been shu*****@gmail.com with the stars omitted for spam purposes.
     
  27. clip911

    clip911

    Joined:
    May 21, 2011
    Posts:
    31
    Santos : it's looking good. U put u r name in software section also??? should'nt be there unity3d? :p
     
  28. Thiago6891

    Thiago6891

    Joined:
    Jun 8, 2011
    Posts:
    22
    @clip911: My gf also complained about the difficulty level. Even the walker boys said it took some "serious clicking" to get through it. When I finish lab2 I'll go back to lab1 and make it easier... even I think it's too difficult sometimes.:rolleyes:

    @Jay_Santos: It's working fine, you'll pass imo.
     
  29. Stec

    Stec

    Joined:
    Apr 13, 2011
    Posts:
    118
    Hey guys, I finished all four labs so I would like to heard some opinion from you. The fourth lab have some minor bugs, but currently I dont have time to fix that, it will be corrected before the Lab 5. Here is the site: http://unity4d.vacau.com/

    Thank you for the reply.
     
  30. Thiago6891

    Thiago6891

    Joined:
    Jun 8, 2011
    Posts:
    22
    @Stec: Well, I can't see anything on the main menu, just the plaques saying "Play game", "help", etc... so I can't even start the game.
    I liked lab2's gui elements btw (player health bar and shield bar), nice little modification from the usual text gui.:)
     
  31. Stec

    Stec

    Joined:
    Apr 13, 2011
    Posts:
    118
    @Thiago6891

    Thank you for the reply, the Lab 4 I created useing the stremed build and the WWW class to load the music form the web to speed up loading process, so it is possible that you have slow internet conection, it loads for me every time and the Boys manage to load it to. But I will increase the duration of the loading screen so that the main menu screen has more time to load.
    I am glad that you like the gui elements on lab 2, I wanted to give the game a bit more "lIfe" so I made that.
     
  32. clip911

    clip911

    Joined:
    May 21, 2011
    Posts:
    31
    Stec; i love the graphics, for mario n u r ship for space shooter
     
  33. Stec

    Stec

    Joined:
    Apr 13, 2011
    Posts:
    118
    Thank you. The ship I downloaded from somewere as a free model, I am learning blender to, but I am still far from that level. In Mario everything is done with sprites, the Boys provide a lot of them, but I have to find some on my own (turtle, plant, boss, walls, torches, etc.)
    Again, thank you for your feedback.
     
  34. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
    @clip / @thiago: Thanks, I gotta be honest, I am not 100% satisfied with it...

    @clip: I'm not sure I understood your question but I did put my name in the credits section and since I have no personal webpage the "Web" button goes to the www.unity3d.com
     
    Last edited: Jun 21, 2011
  35. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
    I'm unable to access your site (www.unity4.vacau.com), is it working?
     
  36. Stec

    Stec

    Joined:
    Apr 13, 2011
    Posts:
    118
    @Jay_Santos

    I just checked your game and it looks greate, nice texture on the asteroids. I would recommend that you build a blog, it is easy and then we can see your projects all in one place.
    As regards of my site, I checked it and it works, it is on the free host so sometimes there is a problem with loading.
     
  37. Jay_Santos

    Jay_Santos

    Joined:
    May 31, 2011
    Posts:
    42
    Yeah, I am seriously thinking of migrating to Wordpress for labs 3 and 4...

    But I would need to recreate my 000webhost account, because When I tried installing wordpress on my site something went wrong, and I never got a reply back from 000webhost support
     
  38. Stec

    Stec

    Joined:
    Apr 13, 2011
    Posts:
    118
    @Jay_Santos

    I followed the tutorials and everything went smooth, if you do not manage to get it working on 000webhost, there is a lot of others free hosts so you can try on one of them. Or you can sent a PM to me if the problems continues, I will try to make an account for you. Good luck.
     
  39. Lifeisagame

    Lifeisagame

    Joined:
    Mar 27, 2011
    Posts:
    1
    Hey guys i'm a Gamedesign student trying to learn Unity so I can build my own prototypes. Really liking this course so far. It sticks to the fundementals and doesn't overcomplicate things.

    I've finished the 1st lab ^^. Learned a lot I think. Really eager to move on to Lab 2.
    posted it over here: http://lifeisagame-unity.herobo.com/wordpress/?page_id=2

    I send a mail to the walkerboys about 1 week ago. Anyone know when I should start to get worried that it didn't make it through the spam filter?
     
  40. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Hi Lifeisagame,

    I've sent a pm to you. I'll go ahead and forward the above link to my brother. :) Thank you.
     
  41. beco13

    beco13

    Joined:
    May 31, 2011
    Posts:
    30
    Just Finished My Lab2 Project...But not yet uploaded it to the word press....Anybody know how to upload it via iMac? Because I'm now using an iMac.At Lab 1 Project I used a Windows OS.
     
  42. xe-cute

    xe-cute

    Joined:
    Jun 17, 2011
    Posts:
    16
    I'm stuck on Lab1 Part 5 06 scripting player click loop.

    Due to the following compile error:

    Code (csharp):
    1. Assets/scriptActorPlayer.js(26,45): BCE0019: 'numberOfClicks' is not a member of 'UnityEngine.Component'.
    Does no one else get this?

    Here is my full scripts which looks correct to me (for the part I am up to):

    scriptActorPlayer.js
    Code (csharp):
    1. #pragma strict
    2. #pragma implicit
    3. #pragma downcast
    4.  
    5. // Player Script
    6.  
    7. // Inspector Variables
    8. var tagName : String = "enemy";                                     // allow the designer to setup a tag in the inspector
    9. var rayDistance : float = 100.0;                                    // length of the ray for our raycast
    10.  
    11. // Private Variables
    12.  
    13. function Update ()                                                          // Update is called every frame
    14. {
    15.     if(Input.GetMouseButton(0))                                             // use the mouse button to select on GO in the scene
    16.     {
    17.         var hit : RaycastHit;
    18.         var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);          // get mouse position
    19.         if (Physics.Raycast (ray, hit, rayDistance))                                // casts a ray against all collidors in the scene
    20.         {
    21.             if (hit.transform.tag == tagName)
    22.             {
    23.                 //var position = Vector3(Random.Range(-6, 6), Random.Range(-4.4, 4), 0);        // new random position of game object
    24.                 //hit.transform.position = position;                                            // move the game object to the new location
    25.                 var enemyScript = hit.transform.GetComponent(scriptActorEnemy);
    26.                 enemyScript.numberOfClicks -= 1;
    27.             }
    28.             else
    29.             {
    30.                 Debug.Log("This is not an enemy!");
    31.             }
    32.         }
    33.     }
    34. }
    scriptActorEnemy.js
    Code (csharp):
    1. #pragma strict
    2. #pragma implicit
    3. #pragma downcast
    4.  
    5. // Enemy Script
    6.  
    7. // Inspector Variables
    8. var numberOfClicks : int = 2;
    9.  
    10. // Private Variables
    11.  
    12. // Update is called every frame
    13. function Update ()
    14. {
    15.     if (numberOfClicks <= 0)
    16.     {
    17.         var position = Vector3(Random.Range(-6, 6), Random.Range(-4.4, 4), 0);  // new random position of game object
    18.         transform.position = position;                                          // move the game object to the new location
    19.         numberOfClicks = 2;
    20.     }
    21. }
    22. // RespawnWaitTime used to hide a game object for a set amount of time and then unhides it
    23. function RespawnWaitTime ()
    24. {
    25.        
    26. }
    27.    
    28. // RandomColor used to change material of a game object
    29. function RandomColor ()
    30. {
    31.        
    32. }
    Also it doesn't matter if I remove the Pragma stuff. Same error. Lastly I know my script names are different but I believe I have accounted for that fact.

    It just hates the line:
    Code (csharp):
    1. enemyScript.numberOfClicks -= 1;
    for some reason.


    I'm completely stumped. Thanks in advance for any help.

    P.S. I am using Indie Win Unity 3.3.0f4
     
    Last edited: Jun 24, 2011
  43. pskicker

    pskicker

    Joined:
    May 30, 2011
    Posts:
    14
    I am done with my Lab2 and I cant register in 000webhost.com, any recommended free webhosting site where I can submit my lab projects?
     
  44. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    http://sites.google.com/

    I'd guess that you have a google account... then again I'd guess like 99% of the world does now. You should be able to upload it there... though I never tried to myself.
     
  45. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Hi PSkicker. You can also get a dropbox account setup for free and post a link from there through the public folder option. :)
     
  46. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    @ xe-cute

    Honestly, I can't find anything wrong with the code....

    So I'm gonna provide you with random guesses... Maybe...

    your enemy object doesn't have scriptActorEnemy attached to it, or maybe not activated on it.
    you haven't saved your enemy script.


    Try this, and see if you get an error, make a function
    Code (csharp):
    1.  
    2. subtractNumberOfClicks()
    3. {
    4.    numberOfClicks -=1;
    5. }
    6.  
    then call that function instead of the variable directly.
     
  47. xe-cute

    xe-cute

    Joined:
    Jun 17, 2011
    Posts:
    16
    I've took out the pragma stuff and even though it didn't fix it the 1st time. This time it did somehow (must be because I removed them lines from all scripts this time).

    So something must be not of strict good code perhaps? Something Dynamic maybe? I'd like to get the code I learn from these to work on Unity iPhone in future so code with :

    #pragma strict
    #pragma implicit
    #pragma downcast

    I think it doesn't like:
    Code (csharp):
    1. enemyScript.numberOfClicks -= 1;
    Is there a better way to do this line of code?
     
  48. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    Code (csharp):
    1. enemyScript.numberOfClicks = enemyScript.numberOfClicks - 1;
    or
    Code (csharp):
    1. enemyScript.numberOfClicks--;
    Both are the same thing written differently. I don't think it being a variable from another script file matters, but I'm not 100% on that.
     
  49. pskicker

    pskicker

    Joined:
    May 30, 2011
    Posts:
    14
  50. Kanly

    Kanly

    Joined:
    Feb 8, 2011
    Posts:
    87
    @ xe-cute

    if you want to call numberOfClicks from another script, you'll need to make it available globally, try making it a static var

    Code (csharp):
    1.  static var numberOfClicks : int =2;
    then you can call it from another script

    Code (csharp):
    1.  scriptname.numberOfClicks -=2;