This used to run fine, all of a sudden I got this strange error.
Any idea? I really hope you see the problem. I’m at 7:59 of this.
This used to run fine, all of a sudden I got this strange error.
So some free form text that you type in, not as a comment, is showing errors. That is expected. You need to enter the text as proper C# code or as a comment. Google for “C# comments” . Also, may I ask a favor. You often come here and mention a video, please don’t do that. We are not going to watch a video. And we always say the same things: “please post your actual code using code tags, and post the error”. Your actual code, not screenshots. Also, you often post these random posts and never return with a follow up, so I feel like we are wasting our time.
void Start()
{
//This is how you write comments, so the compiler knows whatever I type here it shouldn't try to compile
//so this won't create an error
But this isn't C# syntax so obviously will register as a syntax error
}
JeffDUnity3D I apologize. I’ll try to make it not happen again.
So I’m thinking of just starting from the top again. How do you suggest I do this?
Sorry I don’t know what that means, top of what are you referring? Back to your original issue, did you remove the extra text as we mentioned, and did it work?
No.
No matter what I do it just responds with nothing. I believe I need to start again from the top with Visual Studio. Do you also believe so? And if your answer is “Yes” do you have this else to say?
oh man, your english is horrible!
go to google translator, write what you want in your native language then let google translate what you want to english, i hope we can help you more…
What responds with nothing? What are you attempting to do. You don’t really need to restart your training to fix an error that you might be having with this video, just describe the issue. You originally typed in some text that would be expected to cause an error, as we have pointed out. You can’t enter free form text into a code module, it has to be proper C# syntax or a comment. To fix it, delete the text that you typed. But I suspect you are having a separate issue not related to the squiggly lines in your screenshot.
I would suggest just deleting the text which isn’t C# code (lines 16 & 17), saving the file, and if you still have a problem come back here and state specifically what this other issue is.
And as your profile signature states “Feel it Shout it Take off all Feel it Shout it heart burn”, that should fix it! I’m joking of course, but we do need to take the time to write sensible sentences and explain the situation. Do I recall helping you a couple of years ago, where you described an unusual event that caused you to lose the memorized source code for a complete game? Apologies if I am mistaken. Then you tried to learn Nintendo Switch programming more recently, if I recall.
I wonder if he’s saying that his line 19 of code is now causing an error?
he said that it never used to error and now it does, there’s no way he could just type random english in there and have it not error in the past .
Also just as a point of order, if you’re going through Udemy courses and you’re getting errors, its probably going to be much quicker to reach out to other people in the udemy course or udemy themselves as they’ll have the context on what you are attempting to do.
That or just provide more detail on what you are trying to do.
Assets/Scripts/PlayerController.cs(16,19): error CS0103: The name BG1' does not exist in the current context Assets/Scripts/PlayerController.cs(16,9): error CS0103: The name
bgWidth’ does not exist in the current context
are the two errors I’m receiving.
Looks like they’re just variables you haven’t declared, just declare them earlier on in the script and they won’t error anymore.
you need to declare both BG1 and bgWidth.
Hi Brian
As stated above, you’ll need to update the declaration section of your script as shown below…
public Transform BG1;
public float bgWidth;
public float moveSpeed;
public Rigidbody2D theRB;
public Transform bottomLeftLimit, topRightLimit;
Once that’s done, you’ll need to assign the ‘BG1’ transform in the inspector. I assume that it’s a scene background object as in this previous post …
Nevermind, I’ll do it tomorrow when I have more energy…
In the future, this is the only information we need, in addition to the code itself. So provide the code using code tags, and then the error and line number.