Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Should I try to learn C# Before trying Unity?

Discussion in 'General Discussion' started by sumusiko, Feb 19, 2014.

  1. sumusiko

    sumusiko

    Joined:
    Feb 13, 2014
    Posts:
    37
    I have been trying to learn C# but without having someone to personally teach me its a bit hard because theres loads of stuff I just can't understand ... So I wonder if it would be better to learn C# from watching tutorials on how to make games with unity using C# since I know some explain what each thing does and such but still I wonder how effective that would be when it comes to the time when I am the one and only doing the games with no help..
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    11,172
    What materials are you using to try to learn C#?

    Unfortunately if you're just learning from the 'net it can be hard to know good tutes from bad if you're just starting out. I'd strongly suggest going for a book instead, as then there's typically at least some form of quality control.

    As for jumping into Unity, it certainly can't hurt. I still strongly recommend doing both in their own right, but there's no reason to avoid playing with the engine and other tools just because you haven't "learned to code" yet (which is something that you never "finish" anyway).
     
    oopserv316 likes this.
  3. Jzmallz

    Jzmallz

    Joined:
    Jan 26, 2014
    Posts:
    39
    Honestly if you have a strong base in other languages i don't think you really need to try to learn C# to work with Unity because most of the C# you use with unity is Unity modified C# so I would definitely goto the learn section and look at some of the videos they have on scripting but i don't think you are going to need to learn more than that. I learned C#, 1. Because it is very similar to Java and I have a strong base in java, 2. I watched all of the beginner videos, but what I think worked the most for me and helped me learn the most, was watching some Unity tutorials videos on Youtube. You may be different I learn by doing and no way else, but just find out what works for you.
     
  4. Adeno

    Adeno

    Joined:
    Aug 7, 2011
    Posts:
    184
    I believe that each person has a different way of learning. Some learn better in a classroom with an actual teacher, others can learn well on their own by just reading books, while others prefer to learn visually by watching things get done on videos.

    Personally though, I think that in order to create something complicated in any job (like making a game), you need to really understand the basics first. Basics are the foundation by which bigger ideas can be built upon. Great products are results of combinations of little things done right. In my own experience of learning stuff on my own, I found that it's best to always work along what is being taught in the video or books and then experiment with what I've learned. For me, just watching and reading aren't enough. There's a difference between being just an observer and being the person who's actually doing the work.

    Fortunately, if you're trying to make games as a personal hobby or as a way to make money, you can always have "cheat sheets" near you, unlike if you're at school where having access to notes or books during exam time is forbidden. There's no shame in not being able to memorize the syntax or certain formulas right away. We're only human and there's so much stuff that we need to think about.

    I think that what's most important is understanding the idea behind how games work instead of just memorizing stuff that you see in those video tutorials or books. For example, in a typical 3D platformer game, a person might think that the main character needs to be able to jump, so this person writes some code that allows the character to jump off the ground. After testing the jump ability of the character, the person realizes that the main character can still jump while in the air! Why is this so? It's because the person did not consider at which state his character should only be able to jump. The person then writes up code that specifically tells the game that the main character can only jump if only it's on the ground and not in the air. The problem is then solved. Not a lot of books will tell you that you need to limit the states that a character can only jump with, unless it's specifically a book about making 3D platformer games. In other words, most of the time, you'll have to solve your own problems or ask someone else who might have solved a similar problem that you just encountered.

    From experience, I say that in order to learn something, whether it's game programming, visual effects creation, or whatever else, you need to be open to a few things:

    1. Experimentation - it's not enough to just copy whatever the tutorial shows you step by step. You need to fool around with it and see what you can do with it. If a tutorial shows you how to rotate an object horizontally, then try to rotate the object in other directions as well on your own. If a tutorial shows you how to spawn an enemy every few seconds, then try to make enemies spawn whenever you touch a trigger or whatever condition you want.

    2. Problem Solving - it's near impossible to create a perfectly working functional game in just one go, even if it's just the title screen you're working on. Having problems pop up for almost every new code you write is to be expected. This is where your experience experimenting with what you've learned comes in handy. If you experimented with code a lot, you'll have a better idea at what's causing the problems and you'll have a better chance of solving them.

    3. Expose Yourself to More Ideas - just like in other professions, learning is a continuous process. This is definitely very obvious in the world of video games. Different game developers have different ways of making things work in a game. For example, in the Batman Arkham series, counterattacks are done by right clicking the moment an enemy tries to attack. In Metal Gear Rising, counterattacks are done by pressing towards the direction an attack is coming from while also pressing the attack key. Same idea, different execution. No single book or video can cover every gameplay style that exists or will exist in the future. You'll have to play them on your own to experience the differences or at least watch lots of gameplay videos. The more ideas you have on how to implement certain things, the more things you can experiment with, which increases your problem solving and game design experience.

    Good luck and have fun. :)
     
    hacknslashxx likes this.
  5. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,356
    You don't need to learn C# to use Unity, but if you want to become a better Unity developer, having a solid understanding of C# will be a huge bonus and increase your market value and confidence with the software. I'd suggest checking out the C# from scratch video tutorials on www.pluralsight.com. Once you've completed these beginner tutorials you'll be well on your way to becoming a decent Unity scripter, as you get more familiar with the Unity API.

    Not sure what you mean by 'modified' C#. The C# used in Unity has all the same language features for C# up to .NET 3.5.
     
  6. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    11,172
    Yep, including almost all of the standard library.
     
  7. BeginnerGuy

    BeginnerGuy

    Joined:
    Feb 14, 2014
    Posts:
    20
  8. sinisterCookie

    sinisterCookie

    Joined:
    Oct 12, 2013
    Posts:
    244
  9. Grimwolf

    Grimwolf

    Joined:
    Oct 12, 2013
    Posts:
    296
    Using a visual scripting asset like Playmaker should go a long way in reducing just how much programming you need to know to make games in Unity.
    When actually learning programming, the best method I've found personally is to first study up on the basics so you know how to actually do it, and so you have a solid grasp of at least most of what is possible with it (knowing, for example, what things like Loops and Arrays are, how you use them in that particular language, and what they're primarily used for). From there you learn by doing, occasionally looking up answers to any questions you have as they arise. If you're just starting out you'll want to start with small projects and slowly work your way up to more complex things anyway, and that's perfect for learning programming.
     
  10. sumusiko

    sumusiko

    Joined:
    Feb 13, 2014
    Posts:
    37
    Well I'm learning pascal atm just for the basics will move to java really soon however I wanna learn C# for unity3d too because C# is from what I've heard its one of the most versatile languages for everything.

    I also know the basics of C# since I've already been studying it for a few days, I know arrays, functions , classes (although poorly) and such thats why I didn't know if I should move to unity since I know unity isn't 100% like C#.

    @Adeno ty man that actually helped a lot!
     
  11. Deleted User

    Deleted User

    Guest

    One question, why are you learning a dead language? I haven't used Pascal since the early 90's Bordland Delphi stuff.

    If you want to make games, at least learn the likes of C and C++. Shaders generally are written in C and C++ is the core backbone of most commercial game engines, Unity's scripting is an exception to the rule unless third parties have bolted mono on top.

    You are much better off getting familiar with an API and learn the shear basics, Unity provides you with all the basics anyway.

    http://unity3d.com/learn/tutorials/modules/beginner/scripting
     
    Last edited by a moderator: Feb 19, 2014
  12. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,219
    I don't think you need to learn C# before trying Unity. I am learning C# while using it and when I don't know something, google is my friend. In game land, unless you plan on supporting your game for the long time, only three things matters: that game runs fast enough, is bug free and is fun to play. Quality of your code doesn't mean too much, unless as I said you plan on long-term support for your game or unless it hinders game's performance.
     
  13. sumusiko

    sumusiko

    Joined:
    Feb 13, 2014
    Posts:
    37
    I'm learning just the basics of Pascal so I know what each thing does , what they for , etc.. I started learning pascal as a way of being able to get into other languages easier since I already know the basics of programming
     
  14. Deleted User

    Deleted User

    Guest

    There is no real benefit to doing so, learn the basics of C and C++ which will go a long way.
     
  15. sumusiko

    sumusiko

    Joined:
    Feb 13, 2014
    Posts:
    37
    well I wanna be able to make an MMO in the future and I believe the quality of the code really does matter in those since I'm guessing I'm gonna need to code a lot more stuff than just the regular 2d/3d singleplayer games. I wanna make sure everything runs perfectly with no fps issues
     
  16. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,219
    As I said, my advice doesn't apply if you plan on long-term support of your game as it is case with MMO. But for regular, one-shot projects it is more than enough.
     
  17. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    567
    just goto www.unitypro.co.uk and follow some video tutorials at the same time making a game, it's more fun that way and you get to see C# working with Unity's Api
     
  18. RussianGravy

    RussianGravy

    Joined:
    Nov 24, 2018
    Posts:
    2
    Are there any books you'd suggest I read?
     
  19. RussianGravy

    RussianGravy

    Joined:
    Nov 24, 2018
    Posts:
    2
    I'm also interested in learning to program with C#
     
  20. Amon

    Amon

    Joined:
    Oct 18, 2009
    Posts:
    975
    @RussianGravy The first book I would suggest is how not to necropost.
     
    schmosef and DaDonik like this.
  21. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    2,488
    As some already mentioned, learn C# along with practicing in Unity.
    This is how I learned it.
    Replicate online tutorials andLearn section, as you go through.
     
    vakabaka likes this.
  22. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    159
  23. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    12,594
    Amon, angrypenguin and Kiwasi like this.
  24. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,962
  25. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    920
  26. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    2,488
    Unity JS with 2018.3 become obsolete. So no point.
    Why you even look there?
     
    Ryiah likes this.
  27. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    2,960
    They'd update them by removing every reference to UnityScript. This will hopefully happen someday, and we can all get chemical lobotomies to forget it ever existed.
     
    Amon, Ryiah, Kiwasi and 2 others like this.
  28. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,962
    Ryiah likes this.
  29. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    C# 4 or .NET 4? In any case alot has changed.
     
  30. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,962
    Unity 4.0.
     
  31. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    2,960
    Are you talking about the language itself, or the actual code used to access things? ;)

    The language has new additions, but I don't think it's relevant in this context. C# hasn't changed enough that the raw code is no longer valid C# as such. But we definitely need to upgrade code only a few years old because of how they changed how the Unity API changed. And in some cases perhaps the C# API also changed. I'm pretty sure there were some breaking changes in how some classes worked between 2.x to 4.x (at the very least you should stop relying on old bug workarounds).
     
  32. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    Ah, true. But in 2018 you can use .NET 4.5 features (both runtime and C#) ;)

    edit: haha, checked the level of that video clip.. ok.. but they should have used var instead of int though. or just returned the value without storing it in a variable first.
     
  33. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    Or use expression bodied methods

    Code (CSharp):
    1. public int MyFunction(int number) => myInt * number;
     
  34. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,962
    No

    Definitely no.

    These are tutorials aimed at beginners writing their first script. They should use the most basic form of syntax possible.
     
  35. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    Less code, less to learn
     
  36. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    11,172
    More abstraction, more to learn, split over more layers.

    Properly understanding "var" requires someone to first properly understand data types in general.
     
    Amon, Antypodish, vakabaka and 2 others like this.
  37. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,962
    No. You haven't provided them less to learn. You've actually provided them with additional things to learn.

    You've added in additional code syntax with Lambda expressions. Lambda expression is confusing as hell to a beginner programmer. They are going to need to declare methods in the traditional way. Which means you are now asking them to learn two different syntaxes to declare methods.

    var is the same thing. You need to learn explicit variable declarations in order to operate at the class scope. So var is an additional thing that must be learned on top. Again, its two different syntaxes to do one task.
     
    Amon, Antypodish, ikazrima and 2 others like this.
  38. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    Yeah, many here even think var magically turns c# into a dynamic typed language :)
     
  39. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    That's not a lambda it's an expression bodied member. A lambda is a anonymous method.
     
  40. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    11,172
    The fact that you're correcting people on these things only highlights the additional complexities they bring. ;)

    Teaching isn't about demonstrating how smart the teacher is, or showing off fancy code tricks. It's about building knowledge in the learner from the foundations up. Start with the simple stuff and move on once they're confident with it.
     
    Antypodish, vakabaka, orb and 2 others like this.
  41. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,962
    I rest my case.
     
  42. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    You guys are missing the point, someone stated that nothing have changed since Unity 4 and it has. We have 4.5 support since 2018. And that directly effects said example above.

    Should they update the tutorial to expression bodied methods? Thats another discussion. I just dont like it when people write false info
     
  43. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    4,202
    Wait is this another thread that's nothing but anders telling everyone to use var? How many of these do we really need?
     
    Amon, Kiwasi and Ryiah like this.
  44. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    Have you started using them yet? If the answer is no, then they are not enough
     
  45. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    2,488
    Offtopic ;)
    mr
    (-on)
     
  46. ds3427756

    ds3427756

    Joined:
    Dec 6, 2018
    Posts:
    3
    hello,
    according to me. without any course to learn c# is very difficult means you can learn it easily but some concepts are very difficult to learn. if you clear with some basics of c, c++, or java or if you love coding languages then its easy for you to learn c# language i would like to suggest you, please refer some online videos and tutorials or w3school site that helps you better to learn programming language.
    ALL THE BEST!!
     
    Antypodish likes this.
  47. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    2,488
    I used that in very past quite a bit. I think is good suggestion.
     
  48. christoph_r

    christoph_r

    Joined:
    May 20, 2013
    Posts:
    402
    Expression bodied members use syntax established through lambda calculus. It's therefore perfectly reasonable to call it a lambda expression.

    Sorry for keeping on necroing and the mostly useless smartassery but it was too hard to resist..
     
  49. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    3,386
    Here is a lambda using a epxression bodied property

    Code (CSharp):
    1. public Func<int, int> MyLambda => number => myInt * number;
    edit: Dont do this btw, it genererates garbage, both becasue anonymous methods that access members are scoped and we create a new anonymous method each time the property is accessed
     
  50. christoph_r

    christoph_r

    Joined:
    May 20, 2013
    Posts:
    402
    Does that compile in an empty class on your end?