hello Everyone
I am New to Unity and have been working through the pathways I am currently busy with the Junior Programmer create with code 2 But at the part where we are suppose to create the SpawnObstacle method Visual Studio does not want to create it. And I’m doing exactly like it is shown in the tutorial it keeps telling me the following:
Top level statements must precede namespace and type declarations
local function SpawnObstacle() must declare a body because it is not marked ‘static extern’
can anybody please help me fix this
Please paste the whole class and the full error code so we know what line etc.
That just means you’re making typing mistakes.
You can fix your own typing mistakes. Here’s how:
Remember: NOBODY here memorizes error codes. That’s not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.
The complete error message contains everything you need to know to fix the error yourself.
The important parts of the error message are:
- the description of the error itself (google this; you are NEVER the first one!)
- the file it occurred in (critical!)
- the line number and character position (the two numbers in parentheses)
- also possibly useful is the stack trace (all the lines of text in the lower console window)
Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.
Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly? Are you structuring the syntax correctly? Look for examples!
All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.
Errors means you weren’t entering it exactly as shown in the tutorial. Like was mentioned above we need to see the code, but we also need to know the exact entry in the series you were following along with.
It seems like you’re having trouble with the SpawnObstacle method. Double-check if you’ve typed everything exactly as shown in the tutorial. Sometimes small mistakes cause errors.