Stuck - Errors in Unity when I try and run it - 2d course - Lesson 25

I am working on the 2d course - lesson 25

Below is my code:
image

I don’t see any errors in the code, and I compared it to the code in GIT.

I get two errors in Unity:
Assets\AdventureGame.cs(12,11): error CS1519: Invalid token ‘=’ in class, struct, or interface member declaration

Assets\AdventureGame.cs(12,18): error CS1519: Invalid token ‘;’ in class, struct, or interface member declaration

It seems like “State” isn’t pulling from the State.CS, even though its public, if anyone has any ideas, it would be appreciated.

Thanks!

Hi Aaron,

Welcome to our community! :slight_smile:

MonoBehaviour does not have the same colour as your classname. There might be a problem with Visual Studio. Please watch lecture “Fixing Visual Studio Problems” (currently #4).

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?


See also:

That did get me farther - I had to set VS as my editor in Unity.

I am still getting an error though. I actually went and copied all the code from GIT, so I am lost now with this error.

NullReferenceException: Object reference not set to an instance of an object
AdventureGame.Start () (at Assets/AdventureGame.cs:19)

Any help is again appreciated…

NullReferenceException means that a reference (“link”) to an instance is missing. Double click on the error message to see to which line in your code it is referring. If you exposed a field in the Inspector, make sure that it’s not empty.

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

Privacy & Terms