Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

CS1519 Keeps bugging me

Discussion in 'Getting Started' started by Laurts, Oct 26, 2022.

  1. Laurts

    Laurts

    Joined:
    Sep 2, 2022
    Posts:
    2
    Hey! I keep getting a problem with CS1519, and i cant fix this any help?


    Code (CSharp):
    1. 1.  
    2. 2.    public class Carcontrols : MonoBehaviour{
    3. 3.  
    4. 4.  
    5. 5.        public Rigidbody2D backtier;
    6. 6.        public Rigidbody2D fronttier;
    7. 7.        public float speed = 20;
    8. 8.        private float movement;
    9. 9.  
    10. 10.  
    11. 11.  
    12. 12.        void Start(){
    13. 13.          
    14. 14.        }  
    15. 15.    void Update(){
    16. 16.      
    17. 17.        movement = Input.GetAxis ("Horizonatal");
    18. 18.  
    19. 19.        }
    20. 20.    
    21. 21.    
    22. 22.      
    23. 23.        backTier.AddToruqe[movement * speed * Time.fixedDeltatime];
    24. 24.        fronttier.AddToruqe [movement * speed * Time.fixedDeltatime];
    25. 25.    }
    26.  
     
  2. MarekUnity

    MarekUnity

    Unity Technologies

    Joined:
    Jan 6, 2017
    Posts:
    179
    Hey @Laurts,
    This is a 2D forum and it would be better to ask this kind of questions at Getting Started.

    The issue you're having is that line 23 and 24 are outside of closure at line 19. To fix your problem, move these 2 lines above line 19.

    I would also suggest that you go through some tutorials to get better understanding of scripting in C#. Unity Learn or YouTube is a good place to start.
     
  3. iMobCoding

    iMobCoding

    Joined:
    Feb 13, 2017
    Posts:
    160
    And also this:

    upload_2022-10-26_11-30-49.png

    Like @MarekUnity suggested, go through more tutorials, especially about c#, before you dig into the actual game...
     
    MarekUnity likes this.
  4. RichAllen2023

    RichAllen2023

    Joined:
    Jul 19, 2016
    Posts:
    1,026
    The official tutorials on here don't work, they're often at least 2 versions out of date for a start.
     
  5. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    That's a pretty big claim to be making. The Learn tutorials all work for the version of Unity they were published for. And I've yet to find any that had API differences between their version and the latest available. There may be differences in some of the Editor UI, but that's a far cry from "don't work."