Unity C# problem

Associate
Joined
28 Jul 2014
Posts
694
Location
Liverpool
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

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


Code:
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");

}
}
 
Back
Top Bottom