Cannot Solve Parsing Error

Ive been trying to create a simple moving script for a small game, and it keeps giving me a parsing error… from what I keep thinking is a closing bracket. Simply I need help, and all is much appreciated!

My error:
Assets/Scripts/Bounce.cs(58,25): error CS8025: Parsing error

Heres the script:

using UnityEngine;
using System.Collections;

public class Bounce : MonoBehaviour {

float lerpTime;
float currentLerpTime;
float perc =1;

Vector3 startPos;
Vector3 endPos;

boo1 firstInput;
public boo1 justJump;

void Update ()
{
if (Input.GetButtonDown (“up”) || Input.GetButtonDown (“down”) || Input.GetButtonDown (“left”) || Input.GetButtonDown (“right”)) {
{
if (perc == 1) {
{
lerpTime = 1;
currentLerpTime = 0;
firstInput = true;
justJump = true;
}
}
startPos = gameObject.transform.position;

if (Input.GetButtonDown (“right”) && gameObject.transform.position == endPos) {

endPos = new Vector3 (transform.position.x + 1, transform.position.y, transform.position.z);
}
if (Input.GetButtonDown (“left”) && gameObject.transform.position == endPos) {

endPos = new Vector3 (transform.position.x - 1, transform.position.y, transform.position.z);
}
if (Input.GetButtonDown (“up”) && gameObject.transform.position == endPos) {

endPos = new Vector3 (transform.position.x, transform.position.y, transform.position.z + 1);
}
if (Input.GetButtonDown (“down”) && gameObject.transform.position == endPos) {

endPos = new Vector3 (transform.position.x, transform.position.y, transform.position.z - 1);
}
if (firstInput == true) {
{
currentLerpTime += Time.deltaTime;
perc = currentLerpTime / lerpTime;
gameObject.transform.position = Vector3.Lerp (startPos, endPos, perc);
if (perc > 0.8)
{
perc = 1;
}
if(Mathf.Round (perc) == 1)
{
justJump = false;
}
}
}
}

Please use code tag when pasting code.

Sorry, I’ve never had to do that before… Could you support me with some directions on copy and pasting c#?

Remove the curly brace at the end of if case right after your Update method start!

Yeah, it’s looking like a problem going on in this neighborhood of things.

void Update ()
{
if (Input.GetButtonDown ("up") || Input.GetButtonDown ("down") || Input.GetButtonDown ("left") || Input.GetButtonDown ("right")) {
{
if (perc == 1) {

Okay so I solved those ones, and now I’m having issues with line 61…

Error:
Assets/Scripts/Bounce.cs(61,1): error CS8025: Parsing error

using UnityEngine;
using System.Collections;

public class Bounce : MonoBehaviour {

    float lerpTime;
    float currentLerpTime;
    float perc =1;

    Vector3 startPos;
    Vector3 endPos;

    boo1 firstInput;
    public boo1 justJump;

    void Update ()
    {
        if (Input.GetButtonDown ("up") || Input.GetButtonDown ("down") || Input.GetButtonDown ("left") || Input.GetButtonDown ("right")) {
        {
            if (perc == 1) {
            {   
                lerpTime = 1;
                currentLerpTime = 0;
                firstInput = true;
                justJump = true;
            }
        }
        startPos = gameObject.transform.position;

        if (Input.GetButtonDown ("right") && gameObject.transform.position == endPos) {
           
            endPos = new Vector3 (transform.position.x + 1, transform.position.y, transform.position.z);
        }
        if (Input.GetButtonDown ("left") && gameObject.transform.position == endPos) {
           
            endPos = new Vector3 (transform.position.x - 1, transform.position.y, transform.position.z);
        }
        if (Input.GetButtonDown ("up") && gameObject.transform.position == endPos) {
           
            endPos = new Vector3 (transform.position.x, transform.position.y, transform.position.z + 1);
        }
        if (Input.GetButtonDown ("down") && gameObject.transform.position == endPos) {
           
            endPos = new Vector3 (transform.position.x, transform.position.y, transform.position.z - 1);
        }
        if (firstInput == true) {
        {
            currentLerpTime += Time.deltaTime;
            perc = currentLerpTime / lerpTime;
            gameObject.transform.position = Vector3.Lerp (startPos, endPos, perc);
            if (perc > 0.8)
            {
                perc = 1;
            }
            if(Mathf.Round (perc) == 1)
            {
                justJump = false;
            }
        }
    }
}

Extra bracket on line 46 after your IF statement, or following on line 47 if you prefer.

Just tried taking it out / trying to replace it… nope. Still getting a parsing error for line 61.

Same situation on lines 18/19. Take a close look through your script and make sure you have the same number of opening as you do closing brackets.

Yep, from what I counted… 11 and 11.

using UnityEngine;
using System.Collections;

public class Bounce : MonoBehaviour {

    float lerpTime;
    float currentLerpTime;
    float perc =1;

    Vector3 startPos;
    Vector3 endPos;

    bool firstInput;
    public bool justJump;

    void Update ()
    {
        if (Input.GetButtonDown ("up") || Input.GetButtonDown ("down") || Input.GetButtonDown ("left") || Input.GetButtonDown ("right")) {
            if (perc == 1)  {
                lerpTime = 1;
                currentLerpTime = 0;
                firstInput = true;
                justJump = true;
            }
        }
        startPos = gameObject.transform.position;

        if (Input.GetButtonDown ("right") && gameObject.transform.position == endPos) {
            endPos = new Vector3 (transform.position.x + 1, transform.position.y, transform.position.z);
        }
        if (Input.GetButtonDown ("left") && gameObject.transform.position == endPos) {
            endPos = new Vector3 (transform.position.x - 1, transform.position.y, transform.position.z);
        }
        if (Input.GetButtonDown ("up") && gameObject.transform.position == endPos) {
            endPos = new Vector3 (transform.position.x, transform.position.y, transform.position.z + 1);
        }
        if (Input.GetButtonDown ("down") && gameObject.transform.position == endPos) {
            endPos = new Vector3 (transform.position.x, transform.position.y, transform.position.z - 1);
        }

        if (firstInput == true) {
            currentLerpTime += Time.deltaTime;
            perc = currentLerpTime / lerpTime;
            gameObject.transform.position = Vector3.Lerp (startPos, endPos, perc);

            if (perc > 0.8) {
                perc = 1;
            }

            if(Mathf.Round (perc) == 1) {
                justJump = false;
            }
        }
    }
}

I purged the extra brackets from the class you posted above (Found another on lines 20/21), and changed the fact that your bool fields ended in a 1 instead of an L. I’m not able to access a computer at the moment with Unity, but why don’t you throw the above code in as a replacement and see what the compiler spits back at you.

it hapened to me the same but nothing is wrong

Something is definitely wrong; the error never happens for no reason.

–Eric

1 Like

There’s another “extra opening bracket” situation on lines 20/21, as well.