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

I need help fixing a script with the compiler error CS1002

I am having an issue with my incomplete shooting script. I tried testing it out, but I can’t due to the error CS1002. If anyone has the solution to this issue, it would gradually help me out. You can read my code here:

The errors seem to be in line 27 and 28.

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

public class NewBehaviourScript : MonoBehaviour
{
    private StarterAssetsInputs _input;
    // Start is called before the first frame update
    void Start()
    {
        _input = transform.root.GetComponent<StarterAssetsInput>();
    }

    // Update is called once per frame
    void Update()
    {
        if (_input.shoot)
        {
            Shoot();
            _input.shoot = false;
        }
    }

    void Shoot()
    {
        Debug.log("shoot!")
    }
}

I tried to play the game and test it out to see if it was functioning, but I couldn’t test it due to the error.

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

>Solution :

There’s a semicolon missing here:

void Shoot()
{
    Debug.log("shoot!") ;
}

You need to end a C# statement with a semicolon, even if it’s followed by a closing bracket.

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