Search Unity

Best way to learn scripting in Unity?

Discussion in 'Getting Started' started by SnyFort6498, Mar 12, 2017.

  1. SnyFort6498

    SnyFort6498

    Joined:
    Jan 6, 2017
    Posts:
    23
    I have been watching the C# begineer tutorials in the unity page, and i started making a simple game. However, i have lots of issues while programing. If you know alot about scripting, can you tell me how did you learn? (sorry for my english)
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Practice, practice, practice.

    Do all the tutorials you want, but the most important part is to actually use code to accomplish goals you set for yourself. Start with small tasks that you don't know how to do, maybe something like "I want to have a cube that changes to a random color every 2 seconds." Then try doing things that sound more complicated like "I want three cubes to move randomly within a confined area." Combine and add more elements. "I want to have three cubes moving randomly in a confined area, each with a random starting color and full collision detection. If two cubes collide, the slower cube splits into two cubes, each with half the size of their source, and their speed doubles for 10 seconds."

    The key is to task yourself with doing things you don't know how to do, learning how to do that thing, and putting it into action. You'll never be done doing this. But eventually you'll start to realize tasks you once thought were complicated are now second nature to you, and even the most complex of ideas you're now able to break down into smaller tasks that you do know how to approach.
     
    Bisquet, SarfaraazAlladin and Ryiah like this.
  3. SnyFort6498

    SnyFort6498

    Joined:
    Jan 6, 2017
    Posts:
    23
    Okay I will do that, thanks!
     
  4. Gameplay_Johnny

    Gameplay_Johnny

    Joined:
    Mar 10, 2017
    Posts:
    3
    It seems like you have no experience with programming. If that's the case, I would recommend spending a few hours on Codecademy and specifically their JavaScript course. It's free and it gets you to write code right from the get go, which is great. Unfortunately they don't have any C# courses yet, but JavaScript and C# are both object oriented languages so they share a lot of important features like classes, inheritance and so on, meaning that a lot of the knowledge you build will carry over.

    If you're just starting out, I think that spending 10-15 hours on their JavaScript path can help build your confidence with programming in general, at which point any C# materials you consume will make a lot more sense, and you'll also feel more confident tackling stuff on your own like Schneider21 rightfully urges you to do.
     
  5. jenny2325

    jenny2325

    Joined:
    Feb 24, 2017
    Posts:
    15
    I am also new in coding, so i have no experience (hopefully, my question will be not that silly). As I understand the most important basics are C or C++
    Is it better to get familiar with C# and then with Java?
     
  6. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    C, C++, C#, Java, JavaScript, and UnityScript are all different things, and only two of them can be used with Unity.

    UnityScript is sort of a spin-off of TypeScript, which is an object-oriented version of JavaScript, which is the most popular flavor of ECMAScript found on the web. While it used to be fairly popular as it was promoted to draw some of the web developer crowd in, it's now being phased out and most developers here would recommend against spending too much time learning it.

    C# is a language developed by Microsoft which makes great use of its .NET technology stack. It's similar to Java in that they're both managed languages that run in relatively controlled environments. It may seem more complicated to learn than UnityScript at first, but it makes a lot of sense and will actually save you a lot of stress in the long run.

    You'll certainly gain valuable experience from learning C, C++, and Java. But you will not be able to use those languages with Unity.
     
    Ryiah likes this.
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,187
    Once upon a time if you wanted to become a game developer you needed to learn C++. With modern game development that is no longer the case and the only times you'll ever need C++ is if you're building your own engine from scratch, working with the internals of an existing engine, or have very specific requirements.

    C has become even more of a relic. It's primarily used for embedded programming with some very rare use outside of that.
     
    Schneider21 likes this.
  8. Gameplay_Johnny

    Gameplay_Johnny

    Joined:
    Mar 10, 2017
    Posts:
    3
    If your goal is to build games in Unity while learning how to program then your focus should be on C#.
     
  9. tomer20072

    tomer20072

    Joined:
    Dec 8, 2015
    Posts:
    57
    Well it depends on what issues you are having. i would suggest you only learn C#, and i know it's annoying but if you still feel like you can't code then just copy what you see in tutorials from the beginning to the end ,and after you do a bunch of them you'll just feel comfortable writing your own code, and you'll be able to search google and youtube over and over to learn how to do tons of stuff in unity with code, and then it will be fun. i know it's really annoying and you just see the same stuff over and over again but just copy from tutorials all the way through until you feel that you got the basics down.
     
  10. jenny2325

    jenny2325

    Joined:
    Feb 24, 2017
    Posts:
    15
    Wow! Thank you guys! It became a little bit more clear for me. Going through your posts several times. :D
    However, i still have some questions. As far as I understand C and C++ can be used for the game development. So... Is C++ is more advanced or improved version of C? Is it true that knowing C makes easier to learn Java?
     
  11. Dave-Carlile

    Dave-Carlile

    Joined:
    Sep 16, 2012
    Posts:
    967
    Yes, C and C++ can be used for game development, but not in Unity. Although, to be fair you could create plugin dlls in C or C++ and utilize them in Unity, but that would only be needed in some very rare cases.

    I was never much of a C or C++ person, but my understanding is that C++ is kind of a next generation C with some syntax improvements and object oriented capabilities added. That probably just scratches the surface.

    Knowing any language makes any other language easier to learn since the underlying concepts are the same. C# is much closer to Java than C or C++ since they are both managed languages. But I'll stress again as others have that Java is not JavaScript, and JavaScript is not UnityScript which is unfortunately often referred to as JavaScript here.
     
    Ryiah likes this.
  12. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    The C language was released in 1972 and is sort of the grandfather of many modern languages. I'm sure it's still being used in a lot of systems applications today, but I'd wager most software developers don't know or use C anymore.

    C++ was created in 1983 as an object-oriented and improved version of C. It's one of the most prolific languages currently in use, as it's highly effective for both systems and application development.

    Java was created in 1995 by Sun Microsystems and C# in 2000 by Microsoft. They're pretty much children of C++, with the designed intent that they run in managed environments. They've found a strong home in web application development, with C# being Microsoft's .NET stack de facto for desktop applications these days as well.

    Does knowing one language help you learn another? Sure! Since these are all C-based languages, many of the principles translate well from one to the other (though syntax could be very different). Is it necessary? Absolutely not. I've used C# much more than any of the others listed, and although I'd like to dig into C++ a bit more someday, I have trouble justifying why I should.
     
    jenny2325 and Ryiah like this.
  13. jenny2325

    jenny2325

    Joined:
    Feb 24, 2017
    Posts:
    15
    Thank you for your reply. Now it became clear what is the difference between C and C++. Never heard about it previously.

    During the weekend I picked up some good tips here and it became even more clear what to do next. At least now I know where I should start. Thank you for your suggestions.:D