Error CS1525: Unexpected symbol 'void'
I can't seem to find the problem in my script. I'm trying to make a simple ping game, i'm only a beginner and I hate to say every time I fix a problem in my script(C#) a new one pops up. So I think it's time I admit defeat and ask for help. I've narrowed it down to one problem and it's this.
Could anybody help me out? Here's what my script looks like.
Thank you!
Answer by Dave29483 · Jan 30, 2017 at 08:29 AM
Seems this one is all about the braces.
Remove } on line 10, add } at line 16, add { to end of line 20, on line 21 replace last character ( with {, insert } between 23 and 24. Finally add } on line 25.
Also line 22 replace last ) with ;
That should compile at first glance.
Thank you! But I still can't move the object up and down, I hate to ask and be annoying but, any advice on that? Thanks again!
Your code requires W and S to be down at the same time. You need two separate if blocks.
Ugh this is terribly frustrating! I think it's clear I have no clue what i'm doing because another three errors popped up, i'm also terribly sorry again to bother you! I guess I'm still learning. Here's the errors
Here's the script.
Classes, methods and if-blocks all need an opening and a closing curly. Just count them and you'll see you have unequal amount of left and right curly braces. I'm counting 5 lefts and 7 rights.
You haven't used consistent intendation so it's really hard to see which curly is missing a pair. Indent your code so it's easy to see the code blocks. Like this for example.
public class $$anonymous$$yClass : $$anonymous$$onoBehabiour
{
void Start()
{
if (true)
{
}
}
}
Your start()
method will not get executed because you wrote it with lower case s.
Please post your code by copy pasting and using the "101010" button. Someone might even fix your code for you if they could edit yours, but rewriting it all based on a screenshot is too much work and hard to read on e.g. a mobile device.
Your answer
Follow this Question
Related Questions
Error CS0122: inaccessable due to protection level 1 Answer
How to use value from a function in another function 1 Answer
OnTriggerEnter2D problem 1 Answer
Keeping Score out of Update Function 1 Answer
Help with Script 0 Answers