Assets/PlayerCollison.cs(3,43): error CS1003: Syntax error, ',' expected

using UnityEngine;

public class PlayerCollison :MonoBehaviour;
{

void OnCollisonEnter(Collison collisonInfo)
{
if (collisonInfo.collider.tag == “obstacle”);
{
Debug.Log(“We hit an obstacle”);
}
}
}

This is an extremely low effort post. In the future, in the very least, please use code-tags .

The numbers in the brackets (3, 43) mean line 3, column 43. Look there, you’ll see a character that shouldn’t be there.

To note, you’re misspelling “collision” as “collison”. That won’t work for the callback you’ve typed.

1 Like

You’ve placed semi-colons in locations that you shouldn’t (lines 3 and 8), and you’ve misspelled “collision”.

ChatGPT

It looks like there are some syntax errors in your script. I have corrected those for you:

using UnityEngine;

public class PlayerCollision : MonoBehaviour
{

    void OnCollisionEnter(Collision collisionInfo)
    {
        if (collisionInfo.collider.tag == "obstacle")
        {
            Debug.Log("We hit an obstacle");
        }
    }
}

Here are the changes I made:

  • Fixed the class name from PlayerCollison to PlayerCollision.
  • Removed the semicolon after the class declaration (MonoBehaviour; changed to MonoBehaviour).
  • Changed OnCollisonEnter to the correct method name OnCollisionEnter.
  • Removed the semicolon after the if statement.