Coding C# Problem

Status
Not open for further replies.

Affelaffe03

Honorable
Oct 28, 2014
48
0
10,530
Hello there!

So just to say it in beforehand. I have no idea how to code. But I need answers! I am following a tutorial online on how to make a game in Unity. I follow the steps but when I try to play there's this error: error CS8025: Parsing error

This is the script:


using UnityEngine;

[RequireComponent(typeof(PlatformerCharacter2D))]
public class Platformer2DUserControl : MonoBehaviour
{
private PlatformerCharacter2D character;
private bool jump;

void Awake()

{
character = GetComponent<PlatformerCharacter2D>();
}

void Update ()
{
// Read the jump input in Update so button presses aren't missed.
if (Input.GetButtonDown("Jump")) jump = true;
}

void FixedUpdate()
{
// Read the inputs.
bool crouch = Input.GetKey(KeyCode.LeftControl);
float h = Input.GetAxis("Horizontal");

// Pass all parameters to the character control script.
character.Move( h, crouch , jump );

// Reset the jump input once it has been used.
jump = false;
}
}
}


I know that there is just a little Bracket or something that's missing. Please help!

P.S I have NO IDEA where to put this in a catagory so forgive me if this is wrong.
 

DeadlyDays

Honorable
Mar 29, 2013
379
0
10,960
there is one extra bracket that I see, idk if that is just because not everything is copied or what. For every open bracket, you need a close brackets, and there is 1 too many close brackets for the code that is there.

For Coding with this type of syntax, Brackets {} are used to explicitly show the compiler which statements belong to a method/class.
Every line that ends in a semicolon ; is a statement.
After the Class declaration you open a section with a bracket, and after each method declaration you open a section. Because the methods are declared inside the class section because they are listed before the end bracket }, they belong to that class.

So basically it shows sections. So if you designate a section you have to have an open { and a close }, anything inside is in its own section. If you leave it open ended, that it gets confused, or if you try to close it and there is no open.

Also, things initially declared inside a section cannot be referenced from outside of the section, only reference within that section or within sections declared inside that section, like the methods inside the class. That is called scope.
 

Affelaffe03

Honorable
Oct 28, 2014
48
0
10,530




Where is that?
 

USAFRet

Titan
Moderator


I know where.:D
Read your code.
 

Affelaffe03

Honorable
Oct 28, 2014
48
0
10,530


One of them at the very bottom? In the script there is only 2 of them

*update* Wait... No there is 3 of them
 

Affelaffe03

Honorable
Oct 28, 2014
48
0
10,530
Okay I removed it and of course there is another error! This one is: ErrorCS0246: The type or namespace name 'PlatformerCharacter2d' could not be found. Are you missing a using directive or an assembly reference
 

USAFRet

Titan
Moderator


Welcome to the world of debugging...:)
 

Affelaffe03

Honorable
Oct 28, 2014
48
0
10,530


Well thanks! But you are not helping : /
 

DeadlyDays

Honorable
Mar 29, 2013
379
0
10,960
so now it doesn't know where PlatformerCharacter2d is, you either need to include it in the IDE you are using or add another using statement in the very beginning to tell it where PlatformerCharacter2D is.
[RequireComponent(typeof(PlatformerCharacter2D))] this is causing the error, specifically
 

Affelaffe03

Honorable
Oct 28, 2014
48
0
10,530


Eh... Sure.... Just so heh everyone else knows...How do you do that?....
 

Affelaffe03

Honorable
Oct 28, 2014
48
0
10,530


Oh no! I didnt make this script. I wasnt even supposed to do something with it. But when the error came up I had to look into it. Buuuut I have no idea how to code
 
Status
Not open for further replies.