I'm working on a C#7.0 coding project for Unity3D, and am building a script for doors. This comes directly from a project in the book Unity3.X Game Development Essentials which was recommended to me by a gaming professor. I'm learning code on my own, so I'm at the mercy of any updates. For some reason, the code expects an identifier but I'm unsure what identifier it could possibly want. On a level of skill with coding, I'm right above a snail without a shell, so any advice would be greatly appreciated. At one point in time, this code clearly worked because it was published in a book and was recommended by advanced members of staff. I think the code has been updated though. Any thoughts? Any advice? Thanks so much!
Well, the problem is at a line which defines your method Door
.
A method may take input parameters from its caller. Those parameters are variables, available from within the method. Variables are pointers to a memory and their primary goal is to keep information. A variable in C# must always have a type, without a type, variable is meaningless. For example, your variable may be a string (and contain things like "word", "sentence with multiple words" and so on), or integer (1, 5, 1000, -256 and so on), and many many other types.
Your method definition, I believe, is supposed to have three parameters. In C#, when defining a parameter (or a variable), you first write its type, and then its name. Like this: string someVar
, or this: int someOtherVar
.
In your case, you're missing those names. Your method definition containts only types, separated by comma, but no names. Name your parameters and the compilation errors will disappear.
For example, like this:
public void Door(AudioClip doorOpenSound, bool openCheck, string animName)