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 borgger, Jul 10, 2022.

  1. borgger

    borgger

    Joined:
    Jan 19, 2022
    Posts:
    2
    Hi i'm semi-new to unity and one of my scripts keeps giving me this error "Assets\Player.cs(37,28): error CS1003: Syntax error, ',' expected" and I don't know what to do please help.

    Code ↓
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Player : MonoBehaviour
    6. {
    7.  
    8.     public int maxHealth = 6;
    9.     public int currentHealth;
    10.  
    11.     public HealthBar healthBar;
    12.  
    13.     void Start()
    14.     {
    15.         currentHealth = maxHealth;
    16.         healthBar.SetMaxHealth(maxHealth);
    17.     }
    18.  
    19.  
    20.     void OnCollisionEnter(Collision _collision)
    21.     {
    22.         if (_collision.gameObject.tag == "tim")
    23.         {
    24.             TakeDamage(1);
    25.         }
    26.     }
    27.  
    28.     void TakeDamage(int damage)
    29.     {
    30.         currentHealth -= damage;
    31.         if (currentHealth > 0)
    32.         {
    33.            Debug.Log(Aliv);
    34.         }
    35.         else
    36.         {
    37.             Debug.Log(game ova);
    38.         }
    39.  
    40.         healthBar.SetHealth(currentHealth);
    41.     }
    42.  
    43. }
     
  2. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,135
    In the error message "Assets\Player.cs(37,28)" the numbers inside the parentheses tell you the exact location where the error has been made: In row 37 you've forgotten to put the message text inside quotation marks.

    Debug.Log("game ova");
     
  3. borgger

    borgger

    Joined:
    Jan 19, 2022
    Posts:
    2
    Thank you
     
  4. KingRecycle

    KingRecycle

    Joined:
    Jul 20, 2013
    Posts:
    26
    Unfortunately errors can be confusing as it says it's looking for a "," but thats because Debug.Log can have 2 arguments and it sees 2 seperate words in the parens and thinks you wanted to do Debug.Log(game, ova). At least I believe that's what it was expecting. But my point is bug hunting can be confusing for beginners.