Search Unity

Scripting problems in Roll a Ball

Discussion in 'Getting Started' started by fuzzbuddy, Sep 20, 2017.

  1. fuzzbuddy

    fuzzbuddy

    Joined:
    Sep 20, 2017
    Posts:
    8
    Hi I'm new to using Unity and have got stuck with making a script.
    I got up to tutorial 2. Moving the player on Roll a ball when it asks me to make a script.
    I'm using a Windows 10 PC.

    Firstly when I am trying to load Monodevelop, Microsoft's Visual Studio gets in the way and I have to cancel it. (I think it was new with a recent Windows update - should I just delete all Visual Studio apps from my computer?)

    Then I get an error message in Monodevelop:
    "Monodevelop 'could not load project 'Roll a Ball.CSharp.csproj' with unknown item type.

    Also at the bottom of the Monodevelop page I have this error:
    "This file has line endings (UNIX) which differ from the policy settings (Windows)"
    - Convert to windows line endings
    - Convert all files to windows line endings
    - Keep UNIX line endings
    - Keep UNIX line endings in all files

    Any help greatly appreciated.
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Go ahead and let Visual Studio launch if it wants to. Many people feel that's a better editor than Monodevelop anyway.

    (Personally, I use neither; I use Script Inspector 3, ever since that glorious day when I first discovered it.)

    Oh, and the thing about the line endings isn't really an error, it's a warning, and it means exactly what it says. Pick an option. Probably you want "Convert all files to Windows line endings," but I don't think it really matters much.
     
  3. Ichthus

    Ichthus

    Joined:
    Sep 19, 2017
    Posts:
    6
    Happened to me a resembling problem, here is the image: maseufiztudocerto.png

    I did all right with the codes, I thought about simply copy them, but I thought better to do the lesson to KNOW why the code was that way, and understood everything, but then... look inside the yellow square.
     
  4. fuzzbuddy

    fuzzbuddy

    Joined:
    Sep 20, 2017
    Posts:
    8
    Thanks for the help JoeStrout.
    Yes, Icthus I have a similar problem and am trying to work it out:
    Assets/Scripts/PlayerController.cs(20,16): error CS0118: `UnityEngine.Vector3' is a `type' but a `variable' was expected
     
  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    OK, a couple of things...
    • You do not have the Console in your panel layout. You should; the Console is really useful and important. Go to the Window menu, select the Console item at the bottom, and then dock it somewhere handy in your window layout (I suggest below the game view).
    • Now when you get an error, double-click that error in the Console, and it will jump right to that line in the code editor.
    • Also, the error itself contains details about where the error occurred: in the first case, PlayerController.cs, line 11. So, study that line carefully.
    • You may then notice that you have "void Start {}" where it should be "void Start()". (The extra space doesn't actually matter, but using curly braces instead of parentheses does matter — program code is very picky about punctuation and capitalization.)
    You are right to type the code instead of copying & pasting, by the way. Just be very careful, and type it exactly as shown in the tutorial. Good luck!
     
    Ichthus likes this.
  6. Ichthus

    Ichthus

    Joined:
    Sep 19, 2017
    Posts:
    6
    Just to say that I actually done this, I found better to learn and understand what's being done, and sure It was where I mistook myself.

    And thanks for the hints! ;)
     
    Last edited: Sep 20, 2017
    JoeStrout likes this.
  7. Ichthus

    Ichthus

    Joined:
    Sep 19, 2017
    Posts:
    6
    I'm nearly solving! I just still don't figure what's the problem here in the image. Anyone can help?
    quaseconseguindo.png
     
  8. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Hmm. Well I do see one error: on line 19, you have "0,0f" where it should be "0.0f" (in C# you must always use a period as the decimal point, not a comma).

    But the error message indicates something else — and it's weird that it's complaining about column 247 on line 21. This suggests that there is some junk far to the right on that line. Try deleting everything from the ";" (semicolon) to the start of the next line.
     
  9. fuzzbuddy

    fuzzbuddy

    Joined:
    Sep 20, 2017
    Posts:
    8
    I've managed to resolve this by really carefully following the steps involved.
    What I think is confusing and may be a problem is a different between the Roll a Ball tutorial and the Monodevelop screen.

    When Monodevelop loads at the top there are 3 lines of text not just two.
    I deleted this one: "using System.Collections.Generic;" and then matched up all the code to the numbers on the left of the screen.
     
    JoeStrout likes this.
  10. Xype

    Xype

    Joined:
    Apr 10, 2017
    Posts:
    339
    click on the error in console, then where it gives more details at the bottom double click, itll shoot you right to the problem most of the time
     
  11. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    I've noticed that sometimes the reported line number is one below the actual error line. Fixing 0,0f to 0.0f should resolve the problem.
     
  12. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Yeah, but it's the "column 247" that weirded me out (not the line number per se).