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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

error CS1003: Syntax error, ',' expected

Discussion in 'Scripting' started by stevenbos655, May 1, 2020.

Thread Status:
Not open for further replies.
  1. stevenbos655

    stevenbos655

    Joined:
    May 1, 2020
    Posts:
    14
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.sceneManagement;
    3. public class gameManiger : MonoBehaviour
    4. {
    5.     bool gameHasEnded = false;
    6.     public void EndGame (gameHasEnded == false)
    7.     {
    8.         gameHasEnded = true;
    9.     }
    10.     void Restart()
    11.     {
    12.         sceneManager.LoadScene(SceneManager.GetActiveScene().name);
    13.     }
    14. }
    15.  
     
  2. stevenbos655

    stevenbos655

    Joined:
    May 1, 2020
    Posts:
    14
    Assets\gameManager.cs(6,39): error CS1001: Identifier expected
    Assets\gameManager.cs(6,39): error CS1003: Syntax error, ',' expected
    how do i get rid of these errors?
     
  3. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,735
    Code (CSharp):
    1. public void EndGame (gameHasEnded == false)
    Get rid of the nonsensical "gameHasEnded == false" from inside the parentheses.
     
    stevenbos655 likes this.
  4. stevenbos655

    stevenbos655

    Joined:
    May 1, 2020
    Posts:
    14
    thank you I forgot the if statement.
     
  5. Mikos_

    Mikos_

    Joined:
    Aug 24, 2021
    Posts:
    2
    Im having the same probelem...

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Attack : MonoBehaviour
    {
    public Animator animator;
    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.0))
    {
    Attack1();
    }
    }

    void Attack1()
    {
    //play attack animation
    animator.SetTrigger("Attack");
    }
    }

    As far as i know there is a probelem in:

    {
    public Animator animator;
    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.0))
    {
    Attack1();
    }
    }
     
  6. Mikos_

    Mikos_

    Joined:
    Aug 24, 2021
    Posts:
    2
    oh, the error is:
    Assets\Attack.cs(13,37): error CS1003: Syntax error, ',' expected
     
  7. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,003
Thread Status:
Not open for further replies.