Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to Fix Syntax Error CS1003 ',' expected

I am recreating Flappy bird as my first project in unity (version 2021.3.6f1). I’m using Visual Studio to compile the C# script.

I get error CS1003 ‘,’ expected on (8,42)

My Code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public Rigidbody2D rb;
    public FlightForce = new Vector2(0f, 10f);

    // Update is called once per frame
    void Update()
    {
    
        if (Input.GetKeyDown("space"))
        {

            rb.AddForce(FlightForce, ForceMode2D.Force);

        }

    }
}

>Solution :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public Rigidbody2D rb;
    public FlightForce = new Vector2(0f, 10f); // <--- you didn't provide the type here

    // Update is called once per frame
    void Update()
    {
    
        if (Input.GetKeyDown("space"))
        {

            rb.AddForce(FlightForce, ForceMode2D.Force);

        }

    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading