Error CS0122: _ is inaccessible due to its protection level

Hi I am relatively new to unity and have recently run into a error code that i do not know the meaning of here it is

Assets\Dashing.cs(36,12): error CS0122: ‘WASD.dashing’ is inaccessible due to its protection level

2 Answers

2

Hello @FreshWind1020,

WASD is the name of your script, Dashing is the name of a function in your script, “not accessible” means the function is defined with an access specifiers that doesn’t allow other scripts to call it, for example: “private” or “protected” (not putting any access specifiers by default makes the function private)

What you need to do is change the prototype of your function to be public:

void Dashing() {
///
}

Should be:

public void Dashing() {
///
}

thank you so much cyber_cats you are most likely the most helpful person on this whole discussion board

I wouldn't say that ^^' but thanks you are welcome

Hey! Can you send a screenshot please? However this is not a unity error, this is a C# one. Protection level is the following: private: can only be accesed in the class, and not objects. Protected: Can be accesed by sub classes (classes derived) and objects of the class or sub class. Public is can be accesed anywhere. No offence but if you don’t know this, you should learn it first.

I thought thats what it was i was just not was just not totally shure

and i dont know how to fix it

C# is a relatively new language to me, but I know python and arduino

nvm i fixed it founf the line of code that was wrong

I added a reply without seeing this comment ^^'