Search Unity

Complete Scripting novice looking for help with Unity 5

Discussion in 'Getting Started' started by ClutterKat, Mar 14, 2015.

  1. ClutterKat

    ClutterKat

    Joined:
    Mar 14, 2015
    Posts:
    1
    I've never done coding in my life but decided to give Unity a try this week. I've watched hours of tutorials and read everything I could find but when I sit down and trying to use the scripting it says its wrong. All these error messages come up ("unexpected symbols"). I've spent the past 9 hours now trying to figure out what I'm doing wrong. I taken different approaches from different tutorials. I've even gone so far as to copy and paste script in and hoping i could reverse engineer with it to learn what i'm doing. Needless to say it don't work. This isn't a typo issue.
    Is unity 5 that different then past versions that all scripting tutorials, even those on the unity site are just out dated and wrong? All i wanted to do was see if i could move a sprite left and right in a 2D plane. That is all. Should I just drop this for a month or two until there are more tutorials out there? Sprites and collision and psychics work fine its just script does not work.
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    C# is still C#, and UnityScript is still UnityScript. While a few minor things have changed, I don't believe this is what you're running into.

    The best way for people to be able to offer assistance here is with specific problems. Post the script you're having issues with in its entirety (using Code Tags) and the exact errors you're seeing in the console, complete with which lines the errors are occurring.

    That said, the "unexpected symbols" error indicated that the compiler is seeing something it doesn't expect to. For example, to declare a variable in C#, you have your access modifier (public or private), your data type (int, string, bool), and the variable name. Adding words or characters other than these (or assignment operators) will cause the compiler to choke. So the following code:
    Code (CSharp):
    1. public int myNumber + int myOtherNumber = 3;
    would be incorrect because after the variable name "myNumber" only a declaration terminator (semicolon) or assignment operator (equals sign) are valid.

    The best advice I could learn is to just learn a programming language first. C# is great not only because if you learn it for Unity, you know it for a lot of .NET applications as well, not to mention there're more tutorials out there for it. But if you already know a bit of Javascript (I'm assuming you don't), UnityScript is certainly a valid way to go, too.

    You don't have to master the language to be able to work with Unity, but at a minimum you should understand variables and data types, operators, methods, and control structures (if statements, for loops, etc). Once you're comfortable with those, go through the Unity tutorials again. Don't copy and paste code. Ever. Type it out, so it sticks in your head as you consciously think about what you're doing.

    Once you get a ball moving around and feel comfortable striving for more, look into things like object oriented methodology... Classes, inheritance, encapsulation, etc. Go play around again. Come back and look into enumerators and coroutines. There's always more to learn, but you don't have to do it all at once. Just know that the more you learn about programming, the more you'll understand how to approach tasks, and the closer you'll get to realizing your game idea.
     
    OboShape, Ryiah and Effervescent like this.