Having some crazy errors, First time with C# Trying to mess with unity

Error CS0106 The modifier private is not valid for this item. Been having a couple issues with my code, Im a beginning just trying to practice some C# And try to get a movement system down for unity, Followed an instruction...And suddenly im stuck with a whole ton of errors. Sorry if its late, But I need to make progress on this or ill never get around to finishing it
62 Replies
Quiteliterallyno545
Probably would be better to screen shot the error and the code so ill do that now one second!
Angius
Angius2w ago
void not Void C# is case-sensitive
Quiteliterallyno545
Oh its cause I did caps uhhhgggg Looks like that fixed two of the erros! Any thoughts on the not valid errors?
Angius
Angius2w ago
Misplaced braces You close the class after field declarations
Angius
Angius2w ago
No description
Quiteliterallyno545
Really? Huh, Cant tell which ones screwed... Oh I thought... Shit
Angius
Angius2w ago
$structure
MODiX
MODiX2w ago
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;

int LocalMethod(string param) { return 3; }
}
}
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;

int LocalMethod(string param) { return 3; }
}
}
Quiteliterallyno545
It looks like the brace is closed...I apologize, Im really braindead. Especially since this is my first time really diving into C# Im trying to understand
Angius
Angius2w ago
It is closed, but too early
Quiteliterallyno545
Oh? So dont put the brace there?
Angius
Angius2w ago
Makes it so the methods are not a part od it
Quiteliterallyno545
So should I add that brace to the end of the code? Oh up to a certain part *or
Angius
Angius2w ago
No description
Angius
Angius2w ago
Add the closing brace at the end of the class
Quiteliterallyno545
Oh god getting hit with that "What?" from a coder def hurts
wildREA
wildREA2w ago
ah yes... unity
Angius
Angius2w ago
"What?" as in "what is this bit, it's not a part of the class" Not as in "wtf are you doing" lol
Quiteliterallyno545
Oh ok sorry Ok let me try it, Ill update you and you can inform me of how dumb I am
Angius
Angius2w ago
Formatting the code properly helps you spot errors like those. If a method is on the same indentation level as a class, you can tell at a glance that it's not a part of it $prettycode is helpful here
MODiX
MODiX2w ago
To format your code in Visual Studio, Visual Studio Code, Rider, use the following shortcut:
Visual Studio CTRL + K + D
Rider / Resharper CTRL + ALT + L
Visual Studio Code SHIFT + ALT + F
Visual Studio CTRL + K + D
Rider / Resharper CTRL + ALT + L
Visual Studio Code SHIFT + ALT + F
NOTE: the first key must be held while doing it. https://cdn.discordapp.com/attachments/569261465463160900/899513918567890944/2021-10-18_01-26-35.gif
Quiteliterallyno545
Oh boy Well all the brackets in between turned purple
Angius
Angius2w ago
Good
Quiteliterallyno545
Good?
Angius
Angius2w ago
In VS, brackets change color as indentation level changes
Quiteliterallyno545
Gooot it
Angius
Angius2w ago
So now it tells you those methods (purple) are part of this class (yellow) If you add an if or whatever in a method, the braces will be another color yet
Quiteliterallyno545
Alright...So were getting somewhere And three more errors popped up _(;-;)_/
Angius
Angius2w ago
Different errors is progress lol
Quiteliterallyno545
I mean True
Angius
Angius2w ago
Again, case-sensitivity Inputsystem is not the same as InputSystem system.collections.generic is not System.Collections.Generic And so on Seems like VS is not showing any of those issues inline. Probably doesn't give you any autocomplete either. Did you set Unity and VS up correctly for them to work together?
Angius
Angius2w ago
Install & configure Visual Studio Tools for Unity
Connect Unity and Visual Studio and use Visual Studio Tools for Unity to support writing and debugging for cross-platform development.
Quiteliterallyno545
I think I can only offer a slow shrug on that part, Something did break mid way through And It told me I needed SDK When I downloaded it it...Didnt do anything
Quiteliterallyno545
This output could probably give answers but it doesnt do anything for me
Angius
Angius2w ago
Those are messages from VS Code In your screenshots, it's VS
Quiteliterallyno545
Alright yeah its visual studio Is that an issue?
Angius
Angius2w ago
No, you should be using Visual Studio Visual Studio Code is a fair bit less powerful and harder to use overall
Quiteliterallyno545
Oh
Angius
Angius2w ago
So just make sure VS has the Unity workload installed, Unity has the VS plugin, and everything should work fine As per the docs I linked
Quiteliterallyno545
I think I installed the unity VS Plugin, Did it just a bit ago following a tutorial So im not totally sure why that wouldnt be working let me check it out yeah its in But from what I gather from what you said a bunch of stuff is caps when it shouldnt be, So im gonna look it over Entered this and it actually cleared half the errors, Now I have what looks like some...Probably basic errors. No longer having the private error which is just golden. Now its just having problems with wording I..Think
Angius
Angius2w ago
1 and 3 are a casing issue again It really would be much easier if you had the tooling set up properly
Quiteliterallyno545
What is a casing issue, Like...Lowercase and uppercase?
Angius
Angius2w ago
Yes
Quiteliterallyno545
Alright thank god Tooling should be set up but Im not sure why it isnt working
Angius
Angius2w ago
Read the docs I linked
Quiteliterallyno545
My PC Is an anomoly from the void that cannot be understood so it doesnt suprise me
Angius
Angius2w ago
Go step by step See if everything is set up as the docs say
Quiteliterallyno545
Alright I appreciate the help, Ill update if I find anything. Ill go over the doc Well I pretty much fixed all the errors!
Quiteliterallyno545
Which sounds...Kinda good, Until you realizer this is me coding. Went through the doc did what it said and...Didnt seem like anything changed. Went through and cleaned up the cript and...Well
No description
Quiteliterallyno545
Not sure what the hell happened, Might be specifically cause somethings missing I also had the idea to just...Sit and read through all the bits and pieces of the code. Which resulted in me finding random numbers scattered in it. A great example which is suprising that it took long enough to spot is. Onfoot1 Which busted a bunch of the code and I couldnt find out where It came from Nevermind entered one bit of code everything fixed Chad shit
Cattywampus
Cattywampus2w ago
if you see any errors inside your package cache in unity, most probably they're just bogus errors, forcing hot-reloading or restarting your editor will automatically regenerate those cache mismatches while in edit mode.
Quiteliterallyno545
Thats fair! I just ran into a new thingy, That I cant quite make sense of. When I hit play and try to move the capsul around, I get this
No description
Quiteliterallyno545
Which is a bit new Not sure why its coming about now...
Angius
Angius2w ago
Seems like some internal error from Unittm something wrong with their PlasticSCM code
Quiteliterallyno545
Oh god Uhg I dont even know how to fix that
Anton
Anton2w ago
this is a better approach than copy pasting from chat gpt
Quiteliterallyno545
@ZZZZZZZZZZZZZZZZZZZZZZZZZ I apologize for bothering, I debugged a lotta stuff. And I worked. on it a good bit...However for some reason im unable to do any movement options. Meaning I input key, It reads key. And it doesnt move. Im unsure what I did now its saying this again

Did you find this page helpful?