I am trying to make a small farming game similar to the old fashioned Farmville game that was on Facebook. I have made an array to create my land, however when I come to try and see if I can change the grass to a plowed field it doesn’t seem to work.
Visual studio claims there is nothing wrong but Unity says there is an Error with line 58. (Check screenshots)
Just a clarification – Visual Studio is telling you that there are no compile-time problems. You don’t have any typos, invalid syntax, duplicate function names, etc. etc.
That doesn’t mean that you won’t have any run-time problems! Many kinds of errors happen because the language can’t 100% rule them out at compile-time.
In this case, Camera.main was null, and you can’t read the fields of a null object. C#, by default, doesn’t force you to check that an object is not null before using it, so the error can wind up happening at run-time.