Unexpected symbol '}' and a Parsing error

Nothing major here, making a 2D side scroller for fun. However reached a problem here, my two errors are:

  1. Assets/Scripts/Player.cs(60,33): error CS1525: Unexpected symbol `}’
  2. Assets/Scripts/Player.cs(96,1): error CS8025: Parsing error

I’m not very good at coding, but I have a alright grip, but I can’t solve this, everytime I do what it says it just wants me to remove a } from the next line down, until they are all gone, then it is suprised to see ‘Void Update’. Very confused right now. Thanks in advance, code below obviously :slight_smile:

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

//Floats
public float maxSpeed = 3;
public float speed = 50f;
public float jumpPower = 150f;
//public float jumpPower2 = 100f;

//Booleans
public bool grounded;
public bool canDoubleJump;

//References
private Rigidbody2D rb2d;
private Animator anim;

void Start ()
{
rb2d = gameObject.GetComponent ();
anim = gameObject.GetComponent ();

}

void Update ()
{

anim.SetBool(“Grounded”, grounded);
anim.SetFloat (“Speed”, Mathf.Abs(rb2d.velocity.x));

if (Input.GetAxis (“Horizontal”) < -0.1f)
{
transform.localScale = new Vector3 (-1, 1, 1);
}

if (Input.GetAxis (“Horizontal”) > 0.1f)
{
transform.localScale = new Vector3 (1, 1, 1);
}

if (Input.GetButtonDown (“Jump”))
{
if(grounded)
{
rb2d.AddForce (Vector2.up * jumpPower);
canDoubleJump = true;
}
else
{
if(canDoubleJump)
{
canDoubleJump = false;
rb2d.velocity = new Vector2(rb2d.velocity.x, 0);
rb2d.AddForce (Vector2.up * jumpPower)

}
}
}
}

void FixedUpdate()
{

Vector3 easeVelocity = rb2d.velocity;
easeVelocity.y = rb2d.velocity.y;
easeVelocity.z = 0.0f;
easeVelocity.x *= 0.5f;

float h = Input.GetAxis (“Horizontal”);

//Fake friction && if(grounded) = if(grounded == true)
if (grounded)
{
rb2d.velocity = easeVelocity;
}

rb2d.AddForce (Vector2.right * speed * h);
if (rb2d.velocity.x > maxSpeed)
{
rb2d.velocity = new Vector2 (maxSpeed, rb2d.velocity.y);
}
if (rb2d.velocity.x < -maxSpeed)
{
rb2d.velocity = new Vector2 (-maxSpeed, rb2d.velocity.y);
}

}
}

Can you post the code again, except now in CODE tags, I’m lazy to count exactly 60 lines or 96 lines, and I think most of the people are.

please use [code ][/code ] tags when pasting in code to the forums, helps with the readability, there is a sticky on them at the top of the scripting forum.

you are missing a ; at the end of line 59

okay will do, sorry guys

don’t put a space between code and ], and between /code and ]

There’s actually an option under insert in the comment writing section

 using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

    //Floats
    public float maxSpeed = 3;
    public float speed = 50f;
    public float jumpPower = 150f;
    //public float jumpPower2 = 100f;

    //Booleans
    public bool grounded;
    public bool canDoubleJump;

    //References
    private Rigidbody2D rb2d;
    private Animator anim;


    void Start () 
    {
        rb2d = gameObject.GetComponent<Rigidbody2D> ();
        anim = gameObject.GetComponent<Animator> ();
   
    }
   

    void Update () 
    {

        anim.SetBool("Grounded", grounded);
        anim.SetFloat ("Speed", Mathf.Abs(rb2d.velocity.x));

        if (Input.GetAxis ("Horizontal") < -0.1f) 
        {
            transform.localScale = new Vector3 (-1, 1, 1);
        }

        if (Input.GetAxis ("Horizontal") > 0.1f) 
        {
            transform.localScale = new Vector3 (1, 1, 1);
        }

        if (Input.GetButtonDown ("Jump")) 
        {
            if(grounded) 
            {
                rb2d.AddForce (Vector2.up * jumpPower);
                canDoubleJump = true;
            }
            else 
            {
                if(canDoubleJump) 
                {
                    canDoubleJump = false;
                    rb2d.velocity = new Vector2(rb2d.velocity.x, 0);
                    rb2d.AddForce (Vector2.up * jumpPower)           
               
                }
            }
        }   
    }
               

    void FixedUpdate() 
    {

        Vector3 easeVelocity = rb2d.velocity;
        easeVelocity.y = rb2d.velocity.y;
        easeVelocity.z = 0.0f;
        easeVelocity.x *= 0.5f;

        float h = Input.GetAxis ("Horizontal");

        //Fake friction && if(grounded) = if(grounded == true)
        if (grounded) 
        {
            rb2d.velocity = easeVelocity;
        }


        rb2d.AddForce (Vector2.right * speed * h);
        if (rb2d.velocity.x > maxSpeed) 
        {
            rb2d.velocity = new Vector2 (maxSpeed, rb2d.velocity.y);
        }
        if (rb2d.velocity.x < -maxSpeed) 
        {
            rb2d.velocity = new Vector2 (-maxSpeed, rb2d.velocity.y);
        }
           
   
   
    }
}

cheers guys, new here so all the help is good haha

Yeah, LeftyRighty was right, you have a missing ; in line 59, maybe that’s causing the parsing error too

my life is only pain :expressionless: I’ve counting my curly brackets for too long. Thanks again guys :smile:

A good and efficient way to count them is to keep a number in your mind, and if you see a { add 1 to it, and if you see a }, substract 1 from it, it’s 3-2 times faster that way, and it has a lower failure probability too, because your most likely count in the range of 1-5