• Advertisement
Sign in to follow this  

Two Errors With my code

This topic is 2103 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I am following along with this tutorial making a simple 2d Shooter. However I have came across a problem in my code. I am really new to programming I have never done it before. This is my first game where I am using scripts. so I am getting two errors.

First Error
Line(121,9): CS1525 Unexpected Symbol '}'

Second Error
Line(124,1): CS8025 Parsing Error

using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {

enum State

private State state = State.Playing;

public float PlayerSpeed;

public GameObject ProjectilePrefab;
public GameObject ExplosionPrefab;

public static int KillCount = 0;
public static int Lives = 3;

private float ProjectileOffSet = 1.2f;
private float shipInvisibleTime = 1.5f;
private float shipMoveOnToScreenSpeed = 5;
private float blinkRate = .1f;
private int numberOfTimesToBlink = 10;
private int blinkCount;

// Update is called once per frame
void Update ()
if (state != State.Explosion)
//Amount to move
float amtToMove = Input.GetAxisRaw("Horizontal") * PlayerSpeed * Time.deltaTime;

// Move the player
transform.Translate(Vector3.right * amtToMove);

// ScreenWrap
if (transform.position.x <= -13.5f)
transform.position = new Vector3(13.4f, transform.position.y, transform.position.z);
else if (transform.position.x >= 13.5f)
transform.position = new Vector3(-13.4f, transform.position.y, transform.position.z);

//Fire projectile
Vector3 position = new Vector3(transform.position.x, transform.position.y + transform.localScale.y / 2);
Instantiate(ProjectilePrefab, position, Quaternion.identity);


void OnGUI()
GUI.Label(new Rect(10, 10, 10000, 20), "Kill Count: " + Player.KillCount.ToString());
GUI.Label(new Rect(10, 30, 60, 20), "Lives: " + Player.Lives.ToString());

void OnTriggerEnter(Collider otherObject)
if (otherObject.tag == "Enemy" && state == State.Playing)

Enemy enemy =(Enemy)otherObject.gameObject.GetComponent("Enemy");


IEnumerator DestroyShip()
state = State.Explosion;
Instantiate(ExplosionPrefab, transform.position, Quaternion.identity);
gameObject.renderer.enabled = false;
transform.position = new Vector3(0f, -5.0f, transform.position.y, transform.position.z);
yield return new WaitForSeconds(shipInvisibleTime);
if (Player.Lives > 0)
gameObject.renderer.enabled = true;

while (transform.position.y < -2.8)
// Move the ship up
float amtToMove = shipMoveOnToScreenSpeed * Time.deltaTime;
transform.position = new Vector3(0f, transform.position.y + amtToMove, transform.position.z);

yield return 0;

state = State.Invincible;

while (blinkCount < numberOfTimesToBlink)
gameObject.renderer.enabled = !gameObject.renderer.enabled;

if (gameObject.renderer.enabled == true)

yield return new WaitForSeconds(blinkRate);
blinkCount = 0;
state = State.Playing;



If this isn't enough information please feel free to ask me below and I will provide more. Thank you for your help cool.png

Share this post

Link to post
Share on other sites
There is no line 121 or line 124 in the code snippet you posted (it stops at line 120). Did you trim/reformat it before posting (or does the site's code formatter do it automatically)?

You are missing a semicolon on the last line of code.

Share this post

Link to post
Share on other sites
a semicolon at the end of Application.LoadLevel(2); fixes the problem but it gives me another error (86,104): error CS1729:The type 'unityEngine.Vector3' Does not contain a constructor that takes '4' arguments

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement