Search Unity

Assets/MultipleCameraSwitcher.js(5,20): UCE0001: ';' expected. Insert a semicolon at the end.

Discussion in 'Scripting' started by Vampyr_Engel, Jun 26, 2017.

Thread Status:
Not open for further replies.
  1. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Hello yes I pulled down this script to use

    MultipleCameraSwitcher
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var camera1 ; Camera 1;
    4. var camera2 ;Camera 2;
    5. var camera3 ;Camera 3;
    6. var camera4 ;Camera 4;
    7. public var startCamera : int = 1;
    8. function Start ()
    9. {
    10.    camera1.enabled = true;
    11.    camera2.enabled = false;
    12.    camera3.enabled = false;
    13.    camera4.enabled = false;
    14.    startCamera = 1;
    15. }
    16. function Update ()
    17. {
    18.    if (Input.GetKeyDown ("c") && (startCamera == 1))
    19.    {
    20.       startCamera = 2;
    21.       camera1.enabled = false;
    22.       camera2.enabled = true;
    23.       camera3.enabled = false;
    24.       camera4.enabled = false;
    25.    }
    26.    else if (Input.GetKeyDown ("c") && (startCamera == 2))
    27.    {
    28.       startCamera = 3;
    29.       camera1.enabled = false;
    30.       camera2.enabled = false;
    31.       camera3.enabled = true;
    32.       camera4.enabled = false;
    33.    }
    34.    else if (Input.GetKeyDown ("c") && (startCamera == 3))
    35.    {
    36.       startCamera = 4;
    37.       camera1.enabled = false;
    38.       camera2.enabled = false;
    39.       camera3.enabled = false;
    40.       camera4.enabled = true;
    41.    }
    42.    else if (Input.GetKeyDown ("c") && (startCamera == 4))
    43.    {
    44.       startCamera = 1;
    45.       camera1.enabled = true;
    46.       camera2.enabled = false;
    47.      camera3.enabled = false;
    48.       camera4.enabled = false;
    49.    }
    50.  
    and I keep getting this error ''Assets/MultipleCameraSwitcher.js(5,20): UCE0001: ';' expected. Insert a semicolon at the end.'' Can anyone tell me what this means and help me? I got this from the Unity Script Wiki The error doesn't show up in Monobehavour it compiles it and lets it through
     
    Last edited: Jun 26, 2017
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's not the script from the wiki. Did you re-type it instead of copying it? It would be far better and simpler if you just copied the script; that way you'd avoid errors.

    --Eric
     
  3. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I know virtually nothing about unityscript, and would offer a soft suggestion that you try C# instead. It's used a lot more in the tutorials, and online on the forums. If you're just starting, it'd be a good choice (even if you're not).
    However, that being said, a quick google search may have provided an answer:
    Code (csharp):
    1.  
    2. var camera1 ; Camera 1;
    3. var camera2 ;Camera 2;
    4. var camera3 ;Camera 3;
    5. var camera4 ;Camera 4;
    6. // those should all be:
    7. var camera1 : Camera;
    8. var camera2 : Camera;
    9. // and so on
    10.  

     
    cstooch likes this.
  4. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    I tried it the original way it was written and was getting error messages I copied it exactly and was still getting this error message ''Assets/MultipleCameraSwitcher.js(2,20): UCE0001: ';' expected. Insert a semicolon at the end.'' So tried a few modifications and still it didn;t work I would like it to work as I need multiple cameras in my hame but it doesn't not work run the original code and see I am using Unity 5.6 and where is the code supposed to go? On the main camera?
    http://wiki.unity3d.com/index.php/MultipleCameraSwitcher
     
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    I don't use unityscript, so I can't be certain, but

    1. var camera1 ; Camera 1;
    2. var camera2 ;Camera 2;
    3. var camera3 ;Camera 3;
    4. var camera4 ;Camera 4;
    doesn't look right and even after looking at the link you posted, I see that it isn't right. I think you should look a bit closer at the script in the link you posted as the semicolons between should be colons instead...

    Now, if you copied and pasted the script and this error still appeared, then you may have copied something incorrectly. Otherwise, that fix may be enough to fix the error.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There aren't any errors in the original script. It's quite old, but nothing in it conflicts with recent versions of Unity. Copy it using copy and paste, don't re-type it.

    Although, I have to say it's a pretty terrible script, even if technically there aren't any errors. Here's something with the same functionality but better code; attach it to an empty game object.

    Code (javascript):
    1. #pragma strict
    2.  
    3. var cameras : Camera[];
    4. var activeCamera = 0;
    5. var cameraSwitchKey = KeyCode.C;
    6.  
    7. function Start () {
    8.     if (cameras.Length < 2) {
    9.         Debug.LogError ("Assign at least two cameras!");
    10.         return;
    11.     }
    12.  
    13.     for (var i = 0; i < cameras.Length; i++) {
    14.         cameras[i].enabled = false;
    15.     }
    16.     cameras[activeCamera].enabled = true;
    17. }
    18.  
    19. function Update () {
    20.     if (Input.GetKeyDown (cameraSwitchKey)) {
    21.         cameras[activeCamera].enabled = false;
    22.         activeCamera = (activeCamera + 1) % cameras.Length;
    23.         cameras[activeCamera].enabled = true;      
    24.     }
    25. }
    --Eric
     
  7. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK So your saying this will work and the other script is badly written? Can I change this new script to work and to have multiple cameras then?
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Both scripts work.

    --Eric
     
  9. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Eric5h5 OK I tested your new script it runs and actually works unlike the other script(That script passes the debugger but then doesn't run) but It doesn't change to the second camera I put in the scene Wwhy is this please?
     
    Last edited: Jun 26, 2017
  10. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Thats what is peculiar one runs just I can't get the second camera I put in the scene to switch but the first one runs I ran the debugger it passes the debugger but then I get this 'Assets/MultipleCameraSwitcher.js(5,20):UCE0001: ';'' and it will not let me carry on in the scene why is this? What does this error mean?
     
  11. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    I already told you what probably created this error in the first script. You didn't copy the code correctly.

    However, @Eric5h5 script is probably much better, and I would use it instead.
     
  12. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    First of all I was talking to Eric5h4 or anyone else who knows Javascript not you you know why? Because it seems he knows Javascript better than you After all you said you had no idea , Great well I want to talk to someone who has an idea not someone who doesn't I tried to ignore you but it seems you are still going to shove your nose it your probably wondering why I am getting a bit annoyed at this point well thats because I DID COPY IT DOWN AND PASTED IT EXACTLY AS IT WAS WRITTEN IN THE FIRST PLACE I only try to modify something when it doesn't work It doesn't anyone any good just to take down a script and modify it without even knowing whether it works first unless they know exactly what they are doing and even then its quite daft to do so.


    If that error didn't come up after the script debugged and ran do you really think I would be asking why it is not working?
     
  13. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Well, if you choose to ignore help, that is your choice. Good luck! I'll make sure not to try to help you in the future.
     
  14. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Fine but you couldn't help me anyway you said you couldn't help or did you forget? Don't you even read what you type? Or are you just trolliing ? Either way I will look for help from somebody else as you couldn't or didn't want to help now and I doubt you could or want to help in future BYE BYE
     
  15. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I really couldn't tell you what you would or would not do, but I can tell you that the script copied and pasted from the wiki will absolutely 100% not produce errors on those lines. If you later modified it and got different errors, you should have undone your modifications and asked for help on the original errors on the original copied-and-pasted script.

    And seriously.... chill out and be nice, or NO ONE will help you. And as someone who has been on these forums for a long time, @Brathnann is one of the ones that will pretty reliably give you good advice, and (despite the fact that he doesn't know JS because he works in C#) his advice was, in fact, correct. Your modifications to the script are what's causing the errors you are getting. If you back up to the original script direct from the wiki, and still have errors, that's fine; post those errors, and we'll help you work out what is going wrong.

    PS: One of the reasons @Brathnann doesn't know Javascript is that there is virtually no reason to use it in modern-day Unity. C# is, objectively, a better decision, unless you are working on a project with legacy Javascript code. The only reason people like me and @Eric5h5 do know Javascript is because we've been around long enough to remember a time when Javascript served a valid purpose.
     
  16. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Excuse me how many times have I got to say it I COPIED IT AS IT WAS ON THE WIKI AND I TESTED AT LEAST FOUR TIMES AS IT WAS AND IT DIDN'T WORK If he doesn't know Javascript fine why tell someone that and then make out he is helping ? He didn't offer the alternative in C#did he ? And it doesn't say who did the original; script otherwise I would go and ask them Ih by the way there is a link to the original script I put on here you can go and test it yourself if you wish I did fours times before coming on here and about twice afterwards and I was still getting the same erro/

    Don't worry about me asking for tech support from you I won't bother
     
  17. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
  18. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Alright sorry to you I will dump this script and find someone else or struggle on to do it myself I thought that was you for a moment Also I didn't create an account and didn't log in so I didn't see that message underneath or above the script
     
  19. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Actually I have to say sorry and apologies I got the wrong person I should have been talking to Methos5k and not you I apologise
     
  20. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Wow.. this thread.

    My post was correct, ya? :) heh.
     
  21. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    NAH your post was crap troll
     
  22. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Lines 3 through 6 in the code you posted are completely different from the variable declarations in the script on the wiki. So you can say you copy-pasted all day long but unless your copy-paste process changes colons to semicolons and adds numbers after the word Camera........

    And honestly, no one cares. Why even lie about it? And then why double down and lash out at people on top of it?
     
  23. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Wow, you're quite rude. And my post did correct the errors that were in your OP. Yawn. :)
     
  24. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Your code didn't work so you didn't correct any errors YAWN :)
     
  25. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Sweet baby Jesus someone close this thread and burn it with fire.....
     
  26. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Jesus won't help you
     
  27. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Yes, sorry.. no interest in following this any longer.
     
  28. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    What? Look at you all getting mad I tested your code and it didn't work I just got the same results whether modified or not, and now I know why the coder did it this way so it will pass the debugger but not the complier
     
  29. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    People have tried to help you numerous times in this thread. You've been less than cordial. That's your choice, but you could do better.
     
  30. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Let me guess: You copied his code and pasted it into your script blindly, without reading the comment in the middle of it, saying "...These should all be:"? The first few lines were just showing you which lines you had to replace to look like the second set of lines, and so the first few lines would of course still have the same error.

    I'll be honest, I'm mostly following this thread to hear more statements as hilariously ridiculous as this one. Do you even know what those words mean?
     
  31. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Say what you like but I tried it in the original form and the modifications on here and its obvious now unless the guy just got lucky coding it the way he did (which I doubt) the clue is in this statement

     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Closing this since you're nothing but combative and insulting. The original code works fine anyway; you changed it so it doesn't work and then get mad about it, so I don't think you really want any help.

    --Eric
     
    KelsoMRK likes this.
Thread Status:
Not open for further replies.