What is an `invalid token in class` error?

Viewed 54

I've been using a tutorial guide for the game I'm making to figure out the basics and I ran into 2 errors while coding the collisions:

  1. Invalid token "{" in class, struct, or interface member of declaration and
  2. Type or namespace definition, or end of file expected.

Here is the code:

using UnityEngine;

public class PlayerCollision : MonoBehaviour
{
 public PlayerMovement movement;
 {
  void OnCollisionEnter (Collision collisonInfo)
  {
   if (collisonInfo.collider.tag == "Obstacles")
    movement.enabled = false;
  }
 }
}
1 Answers

Looks like you have too many curly braces:

public class PlayerCollision : MonoBehaviour
{
    public PlayerMovement movement;
    void OnCollisionEnter(Collision collisonInfo)
    {
        if (collisonInfo.collider.tag == "Obstacles")
            movement.enabled = false;
    }
}
Related