Search Unity

Learning Unity C# step by step?

Discussion in 'Getting Started' started by BallPitGuy, Feb 15, 2018.

  1. BallPitGuy

    BallPitGuy

    Joined:
    Feb 10, 2018
    Posts:
    9
    Hi!
    I've been trying to learn/teach myself C# and Unity for a little bit, and it's definitely a tough process. I know that other people find it difficult as well.
    So I was hoping that perhaps someone could come up with some kind of baby steps type plan. Not give specific how-to information, but rather a sort of detailed syllabus, just giving baby steps on what to learn and when.
    For example, just like the first day, you learn what variables and functions are. The second day you learn how to use mathf.clamp. (obviously thats kind of a big jump for an absolute beginner, but you get what I mean.)
    Maybe the third day you learn by writing a functioning script for moving a 2D object. Then maybe you learn how to move the 2D object randomly on its own, and then with some constraints. I don't know exactly.
    But it'd be incredibly helpful if someone could outline that for me, since I keep getting distracted and overwhelmed since there are so many things to learn and ways to learn them.
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    One approach if you're being overwhelmed is to simply focus on one of them. Learn the language by itself without the complications brought by Unity. Install Visual Studio (or Xamarin if you're on macOS), download the free C# Yellow Book, and go through it at a slow pace implementing the code in the book.

    http://www.csharpcourse.com/

    It's basically a college text book intended for people just starting with the language so it does explain the code as it goes.
     
  3. Dai-22

    Dai-22

    Joined:
    Jan 19, 2018
    Posts:
    130
    Stick to beginner tutorials from brackeys, charger games, then repeat them to remember the words etc. Also do really basic ball/cube tutorials. The other tutorials involve stuff that very quick to pick up later. Just search for easy unity tutorials on youtube. Roll-a-ball helps you see 3d movement and speed, camera lock etc, others will do different things. I'm only a beginner myself. I find this way best so far, but also watching a couple of random videos in between helps too, just to see the uses. I use C# visual studio old book sometimes also. Going to go over brackeys C# video's 5 to 15 again tomorrow. Just to refresh what iv'e not practiced very well.
     
    BallPitGuy likes this.
  4. BallPitGuy

    BallPitGuy

    Joined:
    Feb 10, 2018
    Posts:
    9

    I appreciate the response. I actually took a look at that book a little while back, but I found that there are some differences between what I know from using Unity, and what the book talks about. Sort of like an app I tried, just called something like "Exercises C#" which asked a question like "if you wanted to print the word "Hello!" what code would you use?" So in Unity you'd use Debug.Log, right? But the app says you would use "System.Console.Write" something or other. Which just confuses me further, since I don't know whether or not it would apply to Unity. The same goes for the SoloLearn learn C# app.
    It's just confusing to me.

    I watched, and took notes, following the Unity scripting tutorials, both the beginner, and intermediate series. But honestly just watch that, I retained about 0% of the information, and even the stuff I did retain, I have no idea how to implement it into any practical form. Does that make sense?
    Learning it is just so tough without any guidance.
     
  5. ThermodynamicsMakesMeHot

    ThermodynamicsMakesMeHot

    Joined:
    Feb 14, 2015
    Posts:
    224
    In coding there will be always more then one way to do something and that's part of the magic. In order to retain anything you have to practice over and over. Watching is not the same as doing it over and over to perfection. Those books and tutorials that talk of learn this and that in 24hrs are are full of it. Sure the content could be decent but it will take a lot longer the 24hrs for you to do anything realistically. Even once you know enough to do things you can fall into that pit of what do I make....or worse yet jump into one project after another never really finishing anything which will leave you even more confused about your skills and place in game dev life.

    All these tutorials about how to code don't teach is the game dev side. You have to draw out and plan your game which I hear some people call "OldSchool". Personally if you draw out a map of what your making and trying to achieve you realize you have all the guidance you need. Ask other for an idea and outline it and then just start doing it. You need a plan, flowchart the actions so you know what's happening. Taking these courses and just copying whats going on is not really learning at an optimal setting. Sure the basics but from there you should just jump right into it. The key is to keep it realistic and timely and don't lose yourself in a project that will take you forever and more. Lots of free and cheap asset complete projects to start you off. I really believe the best way to learn is learning is just start doing it and learning and adapting as you go. Having an asset package project you have a passion for already will help the learning speed exponentially.
     
  6. BallPitGuy

    BallPitGuy

    Joined:
    Feb 10, 2018
    Posts:
    9
    Fair enough, and I agree with you. My only concern is just even still lacking the ability to just "do" anything. Implementing the code is so foreign to me, and I wouldn't know where to start, you know?
     
  7. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Yes, I can understand that. I think everyone is like that in the beginning. That's why writing new things you learn is important, because then you're part of the process (output), not just input lol.
    This is also why I think people learn best with the most fundamental parts, because they're used everywhere. If you skip them, or aren't sure of them, it will trickle through to all of your/their work.

    As for your comment on Console.Write vs Debug.Log (and the like).. yes there are some differences, but if the C# tutorial was just for a console program, and learning basic concepts, most of it could be applied to Unity.
    It doesn't mean you have to do it, it's just an option. I'm sure many people here don't do that. :)
     
    BallPitGuy likes this.
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    Yes, and it's completely normal for that to be the case. You were vague on the time you've been at it other than it being a "little bit" but I know in my case the time it took before I felt comfortable with my first programming language was at least several weeks if not a month or more and it wasn't anywhere near the complexity of a modern language.
     
    BallPitGuy likes this.
  9. Dai-22

    Dai-22

    Joined:
    Jan 19, 2018
    Posts:
    130
    The reason i'm trying to focus on C# in general, is because it is standard for unity and cry engine and visual studio windows console apps etc. Someone online who's a multi-language programmer mentioned that you should learn the "Core" first, it's the same in nearly all programming. That's basically C# visual studio book or similar etc. Covering all basics. Even that is still difficult for me, so i'm looking at C# tutorials also on youtube. It is slow and boring, until I figure something out and can use it. But I haven't figured much out yet :)
     
  10. BallPitGuy

    BallPitGuy

    Joined:
    Feb 10, 2018
    Posts:
    9
    Right, well my "little while" is kind of hard to explain. In the beginning of 2017 I decided I wanted to learn to do this, and so around February 2017 I did the first roll a ball tutorial. Then I kept at it for a couple days, watching tutorials and what not, but I had some issues in my life that kind of ripped me away from everything, and so I picked it back up in like October I think. Then I had some other obligations I had to take care of, and so I've just kind of been trying to learn on and off since then. As of now, February 2018, I decided to really commit to it and work hard at it, hence me being here asking for advice since learning is tough.
    Collectively I've probably used Unity for about 5 hours, haha.
     
  11. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    If you really want to work at learning it and you have time now.. Keep expanding on your 5 hours :)

    Maybe redo Roll-a-Ball, if it's not fresh.
    Add in the space shooter tutorial
    and add in some of these: https://unity3d.com/learn/tutorials/s/scripting

    It's a good mix of learning: fun and "study" lol :) 5 hours is pretty new, so keep at it and "being able to do something/anything" will be in your near future, for sure. Have some fun! :)
     
    BallPitGuy likes this.
  12. BallPitGuy

    BallPitGuy

    Joined:
    Feb 10, 2018
    Posts:
    9
    Alright, I will! Your response was surprisingly inspiring for me, so thank you! I'm going to sit down right now, and do just that. No time like the present!
     
  13. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Yeah, I get the feeling you'll have a good time :) You seem like a positive person, and if life doesn't pull you away for a little while, I'm sure you'll get some good learning done.

    Enjoy yourself :)
     
    BallPitGuy likes this.
  14. BallPitGuy

    BallPitGuy

    Joined:
    Feb 10, 2018
    Posts:
    9
    I try to stay positive, and I'm surprised and happy to see that other people (especially online, for that matter) are the same way! If life pulls me away again, I'll bring my laptop with me this time, haha.
     
  15. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    haha. Cool :)
     
  16. Appleguysnake

    Appleguysnake

    Joined:
    Jan 9, 2015
    Posts:
    19
    OP, I just found this question and I've had the same problem trying to learn programming off-and-on for years. I was doing Unity tutorials and dedicated to practicing, but couldn't get anything to stick. Then I thought of an idea that seemed kind of useful to me and decided to try and make it in Unity (even though it's unnecessary for the idea), and it's been a complete 180. Now all I can think about is how to improve this silly little toy.

    So if you find yourself stuck again, try to think of something you want to make and then just hammer away at it and every time you hit a wall, go back and learn the fundamentals that you're missing. Eventually you'll just restart from scratch and make the project twice as good in half the time. It's not the most structured or straightforward way to learn, but the best way to learn is whatever way actually works for you.

    Also, I highly recommend the Quiz Game series in those scripting tutorials linked above. They're really short and well made and more up to date than the roll-a-ball and space shooter tutorials, and each video covers an extremely useful scripting concept.

    Good luck!
     
  17. BallPitGuy

    BallPitGuy

    Joined:
    Feb 10, 2018
    Posts:
    9
    Oh interesting, alright! But what do you mean "linked above?" Sorry if that's a dumb question, I'm just confused.
     
  18. Dai-22

    Dai-22

    Joined:
    Jan 19, 2018
    Posts:
    130
    if you can't see the space shooter tutorial/ mesh collider, set it o convex in tick box. Also, attach it from inspector window opener for the minimised collider mesh when at that point. That's where I'm only just at character movement...
     
  19. Dai-22

    Dai-22

    Joined:
    Jan 19, 2018
    Posts:
    130
    A little basic help if anyone has the time, a bit of syntax issue?

    Code (csharp):
    1.  
    2. int totalYears = 0;
    3.  
    4.             while (balance < targetBalance)
    5.             {
    6.                 balance *= interestRate;
    7.                 ++totalYears;
    8.             }
    9.             Console.WriteLine("In {0} year{1} you'll have a balance of {2}.",
    10.                     totalYears, totalYears == 1 ? "" : "s", balance);
    11.  
    Ithink this is right unless the slash is wrong, lets see?

    Anyway, it's the == 1 ? "" : "s", that is bothering me...Mainly the ? "" : ...why is there "" between ? :

    I'm not sure what this little part is doing, is it returning a "none" result, so no blank space or character for string is created?
     
  20. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    It's a ternary operator (ternary just means three part) that is designed to allow an expression to choose between two different results based on a condition. Basically it's an if-statement for expressions. You can see the syntax below.
    Code (csharp):
    1. condition ? true_expression : false_expression;
    If we were to rewrite the line of code to use an actual if-statement it might look something like this.
    Code (csharp):
    1. if (totalYears == 1)
    2.     Console.WriteLine("In {0} year{1} you'll have a balance of {2}.", totalYears, "", balance);
    3. else
    4.     Console.WriteLine("In {0} year{1} you'll have a balance of {2}.", totalYears, "s", balance);
    Basically it's just syntactic sugar (code meant to make it easier to read or express your intent).

    https://en.wikipedia.org/wiki/Syntactic_sugar

    References.

    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-operator
    https://en.wikipedia.org/wiki/?:
     
  21. Cedebo

    Cedebo

    Joined:
    Mar 1, 2017
    Posts:
    8
  22. Dai-22

    Dai-22

    Joined:
    Jan 19, 2018
    Posts:
    130
    Thank you. I bookmarked the C# microsoft guide to help for future reference with wrox book i'm using. Or maybe i'll just do the quickstarts sometime to keep me interested.