error CS8025: Parsing error

Hey I am new to the forums and I need a bit of help.

I am currently coding my 2D game for Android and ran into a parsing error along the way. I am coding in C# and I can not seem to get shut of this error, I have tried closing and opening the brackets and still nothing. Any help would be appreciated. Thanks.

Line (30/1) error CS8025: Parsing error

That piece of code is not inside a function block of any sort
Is it supposed to happen every frame? : Put it inside Update

The collisions are meant to happen every time the player hits an obstacle. Here is the full code sheet.

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

private Vector2 fp; // first finger position
private Vector2 lp; // last finger position

void Update () {
foreach(Touch touch in Input.touches)
{
if (touch.phase == TouchPhase.Began)
{
fp = touch.position;
lp = touch.position;
}
if (touch.phase == TouchPhase.Moved )
{
lp = touch.position;
}
if(touch.phase == TouchPhase.Ended)
{
Vector3 newPosition = transform.position;
if((fp.x - lp.x) > 2) // left swipe
{
newPosition.x -=2;
transform.position = newPosition;
}
else if((fp.x - lp.x) < -2) // right swipe
{
newPosition.x +=2;
transform.position = newPosition;
}
}
}
}
}

{
rigidbody2D.velocity = Vector2.zero;
rigidbody2D.AddForce(jumpForce);
}

// Die by being off screen
Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position);
if (screenPosition.y > Screen.height || screenPosition.y < 0)
{
Die();
}
}

// Die by collision
void OnCollisionEnter2D(Collision2D other)
{
Die();
}

public void Die() {
Application.LoadLevel(“gameover”);

}
}

Anybody else help me out with this?

I would gues this is what you wanted:

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {
   
    private Vector2 fp; // first finger position
    private Vector2 lp; // last finger position
   
    void Update () {
                foreach (Touch touch in Input.touches) {
                        if (touch.phase == TouchPhase.Began) {
                                fp = touch.position;
                                lp = touch.position;
                        }
                        if (touch.phase == TouchPhase.Moved) {
                                lp = touch.position;
                        }
                        if (touch.phase == TouchPhase.Ended) {
                                Vector3 newPosition = transform.position;
                                if ((fp.x - lp.x) > 2) { // left swipe
                                        newPosition.x -= 2;
                                        transform.position = newPosition;
                                } else if ((fp.x - lp.x) < -2) { // right swipe
                                        newPosition.x += 2;
                                        transform.position = newPosition;
                                }
                                if ((fp.y - lp.y) > 2) { // up swipe
                                        rigidbody2D.velocity = Vector2.zero;
                                        rigidbody2D.AddForce (jumpForce);
                                }

                        }
                }
   


   
               


// Die by being off screen
                Vector2 screenPosition = Camera.main.WorldToScreenPoint (transform.position);
                if (screenPosition.y > Screen.height || screenPosition.y < 0)
                        Die ();

        }

// Die by collision
void OnCollisionEnter2D(Collision2D other)
{
    Die();
}

public void Die() {
    Application.LoadLevel("gameover");
   
}
}

please use codeblocks for readability.

Like hpjohn said, you have some code just floating out there (the code circled is not in a method for example.) Looking at your class, I cannot even suggest where it should go because it uses variables that don’t seem to exist (jumpForce). Comment that set of code out, or move it into a function and define jumpForce.