I have am error

1 Like

The error message you’re encountering, “Top-level statements must precede namespace and type declarations,” indicates that you have code outside of a namespace or a type declaration in your C# file.

Make sure that the method void OnCollisionEnter(Collision other) is inside a class. In C#, all code must be part of a class or a namespace.

If the error persists, please copy paste the entire script here. Once it has been pasted, highlight the code, and click the </> button to apply code formatting.

Hope this helps!

2 Likes

@Christopher_Powell is right. In the screenshot I can see an extra curly brace on line 24. It ends the class so everything beyond that is in the namespace and not in the class. Code need to be in a class.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms