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 Lesson 1 Draft

Discussion in 'Community Learning & Teaching' started by AnomalusUndrdog, Sep 6, 2011.

Thread Status:
Not open for further replies.
  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,865
    I've never worked with C# but I've checked your code, especially Raycast one, and compared it with Unity's Script Reference codes and eventually found out that your code seems perfect. Only thing I can suggest is, if you are getting an error like that:

    check again that the Camera you use has "MainCamera" tag. If it has, then I am unfortunately out :confused:

    P.S: If error still exists, can you copy the error itself here from Console view, just like the one above...
     
  2. DeZako

    DeZako

    Joined:
    Jan 7, 2013
    Posts:
    3
    That worked as a charm, thanks!

    Edit: by the way, anomalous, you might want to change the 3d models tutorial a bit. It seems that in newer versions, for the PlayerAnimation script to work you need to put it on the Player 3d model, not the parent game object. It has confused me a bit, and only after some fiddling I found the solution.
     
    Last edited: Jan 10, 2013
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,865
    Hi,

    I'm currently at the last lesson but I've some problem with my animations. When I go forward and right, for example, correct animations work together but frequently a frame of another animation (maybe idle) interrupts my animation for 1-2 frame and then forward-right animation works again. And after I walk, my idle animation gets similar interruption while staying in my position.

    Secondly, enemies can hurt me only if I move but I couldn't find the reason.

    Thanks a lot for the tutorials BTW.
     
  4. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Very nice work. Will you have anything on Mecanim in the future?
     
  5. ytwithlove

    ytwithlove

    Joined:
    Mar 14, 2013
    Posts:
    26
    Loving the lessons! Quick question though. I'm on lesson 4 and my Player capsule isn't responding to the spacebar jump input. Does the game object have to be touching the ground in order for it to respond to the jump input? Right now I sort of have it slightly hovering over the ground.
     
  6. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,865
    I've got the same problem. It's about character controller IMO but I couldn't solve it.
     
  7. ytwithlove

    ytwithlove

    Joined:
    Mar 14, 2013
    Posts:
    26
    Glad I'm not the only one having trouble with this. I wonder how you can fix it.
     
  8. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,551
    Oh my god... I made this set of tutorials, like, 3 years ago. I didn't realize people are still reading it.

    It's kinda outdated by now though because it was meant for Unity 3. So regarding updates for new stuff like Mecanim or Shuriken (the new particle system), only when I get the time to revamp this tutorial for Unity 4 will I be able to do that. Perhaps even moving into tutorials for making it into a network multiplayer game.

    As it stands, you have to make use of the legacy animation system, and the legacy particle system, though I believe replicating the look of the particles in the tutorial with Shuriken versions would not be too hard.

    Using Mecanim though, is a different beast. I've just recently figured out how to use it and it's very different. A lot of things that you used to code in the old animation system you can now create in a drag-and-drop approach. Script access to Mecanim could use some improvement (i.e. getting animation layers), though I did read they are slowly exposing more Mecanim features for scripts. Here's Will Goldstone's very good video tutorial on Mecanim: http://video.unity3d.com/video/7362044/unity-40-mecanim-animation-tutorial I have to mention though, if you don't have Pro, some of the things mentioned won't work for you.

    As for the problems you guys are having, I'll look into them once I get home from work, but looking through them quickly, you probably need to share the source code you made so I can diagnose the problem further. Perhaps also screenshots of the Inspector view of your player game object and/or enemy game objects.

    EDIT: pm them to me instead of posting it here so this thread won't get swamped with screenshots
     
    Last edited: Apr 12, 2013
  9. Kagfar

    Kagfar

    Joined:
    Apr 12, 2013
    Posts:
    18
    Is this still the best tutorial even though it's old, or is there something else you'd recommend?
     
  10. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,551
    Well I wouldn't really consider it the best in the first place :p Many parts of it are still relevant i.e. how coding in Unity works. It's just that it teaches the legacy animation system and that you'll probably throw away that knowledge once you start using Mecanim. But for the other parts like raycasting, moving characters, handling keyboard/mouse input, it's not outdated. But I really should get around to updating that...

    Probably the best one right now is from the official unity learn site itself (www.unity3d.com/learn).

    There's also unity3dstudent.com which makes use of more bite-size chunks of tutorials.

    And then there's the Tornado Twins Youtube channel full of video tutorials (http://www.youtube.com/user/TornadoTwins)

    There's really tons out there.

    http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html
    http://unifycommunity.com/wiki/index.php?title=Tutorials

    I can't comment on the quality of those tutorials though as I haven't perused them.
     
  11. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,865
    Hi,

    I haven't watched the new official tutorials of Unity but I can tell you that your tutorials are way better than previous official tutorials of Unity. I'd also recommend a website to begin scripting, which I think is the best ever tutorial to start scripting in Unity: http://www.unityscript.com/lessons1/basics.php

    I too recommend unity3dstudent.com and also there are tons of tutorials at walkerboystudio.com
     
  12. karimovisky

    karimovisky

    Joined:
    Sep 5, 2013
    Posts:
    1
    Hey it's a great tutorials ... i'm in lesson 9 and i can not find the animation
    it give me that error
    IndexOutOfRangeException: Array index is out of range.
    UnityEditor.AnimationSelection.GetClipAtIndex (Int32 index) (at C:/BuildAgent/work/cac08d8a5e25d4cb/Editor/Mono/Animation/AnimationSelection.cs:111)
    please could you help meout of this
     
  13. InfinateX

    InfinateX

    Joined:
    Jan 5, 2014
    Posts:
    1
    This tutorial is great. It's set up very similar to my programming class, so learning is easy. I wish all subjects had classes like this!
     
  14. SavageXX

    SavageXX

    Joined:
    Jan 7, 2014
    Posts:
    1
    Hi, 1st of all thanks for the very good lessons.I am on 9th lesson and i met my 1st problem, when i add the animation on enemys, animation just doesnt work, the continue to slide on me...what happens?
     
  15. seek3r

    seek3r

    Joined:
    Jan 31, 2014
    Posts:
    1
    Hey. I found this on reddit, but I felt like I needed to say thanks here too. I been looking so hard for a non-video based tutorial so I can wrap my brain around Unity. I just don't learn well from a video. I need to read it, rather than see it. This is *exactly* what I been hunting for, as all the rest of the text based tutorials basically amount to: "Here, read the documentation/wiki".

    This will help a lot. Maybe I can finally figgure this out and get Unity to work for me.

    Once again, kudos, thanks, 1000 blessings and an extra slice of raisin pie for you. :D
     
  16. upik

    upik

    Joined:
    Feb 10, 2014
    Posts:
    1
    I found this very helpful, thanks a lot!! :)
     
  17. Blackunknown

    Blackunknown

    Joined:
    Feb 18, 2014
    Posts:
    2
    I'm also new to Unity and these tutorials helped me out a lot. Thanks a lot for making these. I figured there were more people like me that got stuck on the zombie animations so here is my simple attempt to explain how to make animations work. Notice this is not really polished.

    Step 1: Delete the EnemyAnimator script section from Enemy.
    Step 2: Right click somewhere in your assets and create an Animator Controller.
    Step 3: Double click this controller. This will open up the animation window.
    Step 4: Open the folder Zombie in the Assets window.
    Step 5: Drag the Move1 animation from the Assets window to the animation window.
    Step 6: Right click Any State and select Make Transition. Connect this transition to the Move1 animation.
    Step 7: Save the animation controller.
    Step 8: Go to the ZombieMixamo object under Enemy and locate the Animator component.
    Step 9: Click on the little button behind controller and add your animator, I called mine EnemyAnimator.
    Step 10: Press the Apply button to apply this to all the prefabs.

    Reference to where I found the solution: http://unity3d.com/learn/tutorials/modules/beginner/animation
    That is all there is to it. Enjoy!
     
  18. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,551
    Goodness, I hadn't realized people are still replying to this thread! To all those saying thanks, you're welcome. Maybe I have it in me to be a teacher after all :p

    @Blackunkown: Thanks for that. Just note that that will make it use Mecanim, the new animation system, but the tutorials I made use the legacy animation system. That'll work for the zombies, cause they really just play the walk animation over and over and nothing else. The player though, is quite a bit more complex.



    My thoughts on Mecanim with regards to using it over the legacy animation system:

    Now that I've used Mecanim for quite a bit, I'm not so quick to say you'd want to throw away the legacy animation system anymore just like that. Some Mecanim properties still aren't exposed to script, at least, not since I last checked. For me, this limits the amount of stuff I can do with it programmatically. Even as an artist fiddling around with the visual editor for animations, there's still some usability issues (still can't reorder the layers I see). Same goes for Shuriken, the new particle system.
     
  19. dragonboy77

    dragonboy77

    Joined:
    Mar 17, 2014
    Posts:
    2
    Its one of the best tutorials I have seen yet, or at least for me, I found it to be really good especially for someone really new like myself with no programming experience. I'm having big problems with some things but I'm going to work through them eventually I hope. mostly with the lesson 10. I cant get the zombies to use the walk animation and then I'm getting other bugs with that lol...

    If you were to update this series, or turn it into a book it would be something I would definitely be willing to purchase!!

    There are very few resources out there for third person games in unity. funny enough this is exactly the kind of game I wanted to make (3rd person horde game) and it will allow me to build upon it to bring it further.

    I think you should know your efforts are well placed sir: you are a fantastic teacher! :)

    Claudio


     
  20. maltadirk

    maltadirk

    Joined:
    Mar 12, 2014
    Posts:
    43
    @AnomalusUndrdog amazing stuff!! :)
    Would be really cool if you could have something similar with regards to 2D for the new features in Unity 4. Just a suggestion ;)
    Thanks again
     
  21. supercorbyn

    supercorbyn

    Joined:
    Mar 28, 2014
    Posts:
    1
    what language are these in?
     
  22. ReploidX9

    ReploidX9

    Joined:
    Aug 13, 2014
    Posts:
    2
    I'm on lesson 9 atm, and im trying to animate by player 3d model but when i test run the game, any movement makes me fly into the air

    Any ideas?
     
  23. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,865
    If your player has a capsule collider or something like that, try removing it.
     
    ReploidX9 likes this.
  24. HarishDamodaran

    HarishDamodaran

    Joined:
    Feb 14, 2014
    Posts:
    3
    I am looking to learn how to import and save data into and from Unity.

    I need to access data from a device- the device can save a text file or an excel sheet. I want to read this file in Unity and control the speed of my character based on the device.

    Likewise I want to save a text or excel file with the data from the device and how the player performed.
    Can some one show me how ? Which of the tutorials above (or any other) can help me towards it ?

    Thanks.
     
  25. ReploidX9

    ReploidX9

    Joined:
    Aug 13, 2014
    Posts:
    2
    Bingo, thanks.
     
  26. marqha

    marqha

    Joined:
    Sep 24, 2014
    Posts:
    1
    Ty for tutorial. its nice
     
  27. tranhuytk

    tranhuytk

    Joined:
    Nov 2, 2014
    Posts:
    2
    I working with Unity is 1 month
    Unity 4.0 If you have problems Animations Zombi or Player, click ZombieMixamo.fbx from project view, tab Rig, Animation Type: chose Legacy.OK
    I have a problem, If Player don't move,Zombi not Attack Player, health not --

    Code (CSharp):
    1. void OnTriggerStay(Collider other)
    2.     {
    3.         if (other.tag == "Player"  && Time.time >= _nextTimeAttackIsAllowed)
    4.         {
    5.             Health playerHealth = other.GetComponent<Health>();
    6.             playerHealth.Damage(_damageDealt);
    7.         //    Debug.Log("we're colliding with player!");
    8.             _nextTimeAttackIsAllowed = Time.time + _attackDelay;
    9.         }
    10.     }
     
  28. tranhuytk

    tranhuytk

    Joined:
    Nov 2, 2014
    Posts:
    2
    Wow I have solved the error problem, If Player don't move,Zombi not Attack Player, health not --
    Changes:
    Code (CSharp):
    1. if (other.transform.root.tag == "Player"  && Time.time >= _nextTimeAttackIsAllowed)
    2. Health playerHealth = other.GetComponentInParent<Health>();
    Full code EnemyAttack.cs

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class EnemyAttack : MonoBehaviour {
    5.  
    6.     float _nextTimeAttackIsAllowed = -1.0f;
    7.  
    8.     [SerializeField]
    9.     float _attackDelay = 1.0f;
    10.  
    11.     [SerializeField]
    12.     int _damageDealt = 5;
    13.  
    14.     [SerializeField]
    15.     GameObject _hitEffectPrefab;
    16.  
    17.     void OnTriggerStay(Collider other)
    18.     {
    19.         if (other.transform.root.tag == "Player"  && Time.time >= _nextTimeAttackIsAllowed)
    20.         {
    21.  
    22.         //    Debug.Log("we're colliding with player!");
    23.  
    24.             Vector3 hitDirection = (transform.root.position - other.transform.position).normalized;
    25.             Vector3 hitEffectPosition = other.transform.position + (hitDirection * 0.01f) + (Vector3.up* 1.5f);
    26.             Quaternion hitEffectRotation = Quaternion.FromToRotation(Vector3.forward, hitDirection);
    27.             Instantiate(_hitEffectPrefab, hitEffectPosition, hitEffectRotation);
    28.  
    29.             Health playerHealth = other.GetComponentInParent<Health>();
    30.             playerHealth.Damage(_damageDealt);
    31.  
    32.             _nextTimeAttackIsAllowed = Time.time + _attackDelay;
    33.        
    34.         }
    35.     }
    36.  
    37.     void Start () {
    38.    
    39.     }
    40.    
    41.     void Update () {
    42.    
    43.     }
    44. }
    45.  
     
  29. Tahsin Amio

    Tahsin Amio

    Joined:
    Dec 30, 2014
    Posts:
    1
    Is there any way I can download Your game sir? So, i can compare it with mine.
     
  30. FallenGord

    FallenGord

    Joined:
    Mar 3, 2015
    Posts:
    1
    i get a 404 message in lesson 1 when i try to find the downloaded LessonAssets zip file....
    does it still exist, cos this looks by far better at explaining and everything else i've seen
     
  31. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,865
  32. Astenore

    Astenore

    Joined:
    Jul 9, 2015
    Posts:
    1
    hello guys , I'm following this tutorial in Unity 5 free, I have a problem , in chapter 10, in the health script, when I

    add the line:
    Destroy(GetComponent<EnemyMovement>());
    I get the following error :
    - Assets/Standard Assets/CrossPlatformInput/Scripts/Health.cs(34,63): error CS0246: The type or namespace name
    `PlayerMovement' could not be found. Are you missing a using directive or an assembly reference?

    - Assets/Standard Assets/CrossPlatformInput/Scripts/Health.cs(34,42): error CS1502: The best overloaded method
    match for `UnityEngine.Object.Destroy(UnityEngine.Object)' has some invalid arguments

    - Assets/Standard Assets/CrossPlatformInput/Scripts/Health.cs(34,42): error CS1503: Argument `#1' cannot convert
    `object' expression to type `UnityEngine.Object'

    same thing for :
    Destroy(GetComponent<RifleWeapon>());
    Destroy(GetComponent<EnemyMovement>());
    Destroy(GetComponent<PlayerMovement>());

    The error does not occur when I insert:
    Destroy(GetComponent<PlayerAnimation>());
    Destroy(GetComponent<CharacterController>());

    I am following the tutorial to the letter , where am I wrong?
    thank you for patience, I'm a newbie.

    Health.cs
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4.     public class Health : MonoBehaviour
    5. {
    6.          [SerializeField]
    7.         int _maximumHealth = 100;
    8.        
    9.          int _currentHealth = 0;
    10.        
    11.          override public string ToString()
    12.          {
    13.          return _currentHealth + " / " + _maximumHealth;
    14.          }
    15.        
    16.          void Start()
    17.          {
    18.              _currentHealth = _maximumHealth;
    19.              }
    20.        
    21.              public void Damage(int damageValue)
    22.              {
    23.             _currentHealth -= damageValue;
    24.            
    25.                  if (_currentHealth < 0)
    26.                  {
    27.                  _currentHealth = 0;
    28.                  }
    29.                  if (_currentHealth == 0)
    30.                  {
    31.                  Animation a = GetComponentInChildren<Animation>();
    32.                  a.Stop();
    33.                      //Destroy(GetComponent<PlayerMovement>());
    34.                      //Destroy(GetComponent<PlayerAnimation>());
    35.                      //Destroy(GetComponent<RifleWeapon>());
    36.                      //Destroy(GetComponent<EnemyMovement>());
    37.                      //Destroy(GetComponent<CharacterController>());
    38.                      Ragdoll r = GetComponent<Ragdoll>();
    39.                      if (r != null)
    40.                      {
    41.                      r.OnDeath();
    42.                      }
    43.                      }
    44.              }
    45.          }
     
  33. L_Z

    L_Z

    Joined:
    Jan 31, 2016
    Posts:
    2
     
  34. L_Z

    L_Z

    Joined:
    Jan 31, 2016
    Posts:
    2
    try to tag the camera as camera and see if it works :)
     
  35. body4489

    body4489

    Joined:
    Apr 18, 2016
    Posts:
    2
    Thank you very much
     
  36. cihat20

    cihat20

    Joined:
    Apr 30, 2016
    Posts:
    1
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Please be aware that this post is 4 years old and the OP has not posted for more than 3 years. These tutorials are for a long since obsolete version 3.x) and may not be relevant. Don't expect anyone to update links or answer questions. As such, I am closing this thread.
     
Thread Status:
Not open for further replies.