Search Unity

error CS1002 in my unity code

Discussion in 'Scripting' started by pokemonmaster101, Jul 25, 2019.

  1. pokemonmaster101

    pokemonmaster101

    Joined:
    Jul 25, 2019
    Posts:
    1
    Hi! So /i was writing my first code and there of course, I faced a problem.
    The program says playermove.cs(17,2): error CS1002: ; expected
    But the thing is that there is no code in this line, how could be that a problem?

    Also, Im writing my code on Visual Studio Code, because for some reasons, I cannot download Visual Studio (and the newest Unity, because my software is older than required)

    Please help!

    My Code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class playermove : MonoBehaviour {
    6.  
    7. private Animator anim;
    8. private SpriteRenderer sr;
    9.  
    10. private float speed = 3f;
    11.  
    12.     // Use this for initialization
    13.     void Awake () {
    14.         anim = GetComponent<Animator>();
    15.         sr = GetComponent<SpriteRenderer>
    16.  
    17.     }
    18.  
    19.     // Update is called once per frame
    20.     void Update () {
    21.         Move();
    22.      
    23.     }
    24.  
    25.     void Move () {
    26.  
    27.         float h = Input.GetAxisRaw("Horizontal");
    28.  
    29.         if(h>0) {
    30.             // going to the right side
    31.  
    32.  
    33.         } else if(h<0) {
    34.  
    35.         }else if(h == 0) {
    36.  
    37.         }
    38.      
    39.     }
    40. } // class
    41.  

    Update: The error message doesn't show anymore, now it just writes 'All compiler errors have to be fixed...'. I googled it, didn't find any problem, though.
     
    Last edited: Jul 25, 2019
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
  3. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Missing parentheses and semicolon at the end of line 15:
    Code (csharp):
    1. sr = GetComponent<SpriteRenderer>();