C
C#12mo ago
Blitz

Help with Code in Unity

I keep getting this error in Unity and I don't know what I'm doing wrong. I'm new to C# and got this from a youtube tutorial
No description
No description
15 Replies
Jimmacle
Jimmacle12mo ago
for one, your class is not in a namespace but your actual error is because you have code in your class that should be part of a method but isn't lines 32-53
Blitz
BlitzOP12mo ago
How do I put it in a namespace?
Blitz
BlitzOP12mo ago
Should it be like this?
No description
Blitz
BlitzOP12mo ago
And I should copy that class line and put it between lines 32-53?
Angius
Angius12mo ago
You probably shouldn't name the namespace class Namespaces, customarily, follow the folder structure in the project And lines 32-53 should be inside of some method Idk which one exactly, but some
Blitz
BlitzOP12mo ago
Alright so what am I exactly suppose to do?
Angius
Angius12mo ago
I just told you 1. Name the namespace properly 2. Place the aforementioned code where you want it to be executed
Blitz
BlitzOP12mo ago
So name it something like this?
No description
Blitz
BlitzOP12mo ago
Since I have the script in my Characters folder
No description
Blitz
BlitzOP12mo ago
Alright last thing, I got the same error on a different line
No description
Blitz
BlitzOP12mo ago
This is the code now
No description
Jimmacle
Jimmacle12mo ago
i think you should stop copying and pasting things and learn basic C# syntax unity is kind of a rough place to start if you're a beginner $helloworld
Angius
Angius12mo ago
Well, yeah, pretty much the entirety of your code is outside of the class now I second Jimmacle here Learn the basics of C# first
Want results from more Discord servers?
Add your server