please help

Assets\PlayerCollision.cs(6,6): error CS0116: A namespace cannot directly contain members such as fields or methods
how do i fix
this is my code im new to coding

using UnityEngine;
public class PlayerCollision : MonoBehaviour {
public PlayerMovement movement;
}
void OnCollisionEnter(Collision collisionInfo)
{
UnityEngine.Debug.Log(collisioninfo.collider.name);
{
UnityEngine.Debug.Log(“we hit an obstacle”);
}
{
if (collisionInfo.collider.tag) (“obstacle”);
}
}

Fourth line. You’re closing the definition of the class with the closing curly brace before you finish defining it.

thanks for the help but could i have an exaple

What about learning the basics first?

https://unity3d.com/learning-c-sharp-in-unity-for-beginners

2 Likes

Hi, I hope you solved your problem!