Script Errors and Unable to make game object a serialized field

Hi! New to Unity and I’m running into a few issues in the Delivery Driver section of the C# Unity Game Developer 2D course. Any help is much appreciated! :pray:

When I try and open the file, it warns me it’s opening in safe mode.

I open the file in safe mode, these are the errors I get -

This is what my Collision C# script looks like (along with an error saying I don’t have the .NET Core SDK)

But I’ve downloaded the .NET Core SDK, confirmed I downloaded in my terminal (‘which dotnet’ produces a path), and I’ve restarted everything.

I don’t know if the above issues are related, but once I exit safe mode, that’s when I run into my major issues.

I can’t seem to make a serialized field out of a Game Object

I don’t see what’s the issue in my script, but it’s not coming up in the Unity interface as an editable field

I was able to make serialized fields out of the steer speed and move speed, but I’m stumped on this.

Some things I’ve checked / tried:

  • In Unity, I checked my Package Manager and Visual Studio Code Editor is verified and version 1.2.5
  • Unity > Preferences > External Tools - the external script editor is set to Visual Studio Code
  • These are the extensions I’ve downloaded in Visual Studio Code
  • For the C# addon, in the settings, I set Omnisharp: Use Global Mono to ‘always’

Hi Striker,

Maybe there is a conflict between the classnames. UnityEngine contains a class named Collision. Try to rename both your class and your script.

Did this fix it?


See also:

Thank you for the suggestion! I renamed it and this resolved the errors concerning the ‘Collision’ file.
I still get prompted to enter safe mode and have this error -

This is the Follow Camera code

I’m unsure how to make VSC recognize game object and make it a serialized field.

All variables have to be defined before you are able to use them. Where is thingToFollow defined in your code?

It worked!! :smiley: I defined the variable and no longer get prompted to enter safe mode, and the serialize field came up.
I have no idea how I missed that discrepancy in my code from the lesson. Thank you Nina!

Good job on fixing the issue! And don’t worry. These mistakes happen to all of us. :slight_smile:

1 Like

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

Privacy & Terms