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

Error CS1002 Expected

Discussion in 'Scripting' started by Nallen11, Jan 22, 2021.

  1. Nallen11

    Nallen11

    Joined:
    Jan 22, 2021
    Posts:
    4
    Hello guys. I'm new to Unity and C# and I got this error:

    Assets\Scenes\Scripts\PlayerMovement.cs(16,28): error CS1002: ; expected

    What can I do?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerMovement : MonoBehaviour {
    6.     public float movementSpeed;
    7.     public Rigidbody2D rb;
    8.  
    9.     float mx;
    10.  
    11.     private void Update() {
    12.         mx = Input.GetAxisRaw("Horizontal");
    13.     }
    14.  
    15.     private void FixedUpdate() {
    16.         Vector2 = movement new Vector2(mx * movementSpeed, rv.velocity.y);
    17.  
    18.         rb.velocity = movement;
    19.     }
    20. }
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Code (CSharp):
    1. Vector2 = movement new Vector2(mx * movementSpeed, rv.velocity.y);
    should be
    Code (CSharp):
    1. Vector2 movement = new Vector2(mx * movementSpeed, rv.velocity.y);
     
    Bunny83 and Nallen11 like this.
  3. Nallen11

    Nallen11

    Joined:
    Jan 22, 2021
    Posts:
    4
    Thanks !!!

    Now is working ! :D
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Havyx, Bunny83 and Nallen11 like this.
  5. Nallen11

    Nallen11

    Joined:
    Jan 22, 2021
    Posts:
    4