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 {
//Playing
//Explosion
//Invincible
enum State
{
Playing,
Explosion,
Invincible
}
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);
if(Input.GetKeyDown("space"))
{
//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)
{
Player.Lives--;
Enemy enemy =(Enemy)otherObject.gameObject.GetComponent("Enemy");
enemy.SetPositionAndSpeed();
StartCoroutine(DestroyShip());
}
}
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)
blinkCount++;
yield return new WaitForSeconds(blinkRate);
}
blinkCount = 0;
state = State.Playing;
}
else
Application.LoadLevel(2)
}
}
If this isn't enough information please feel free to ask me below and I will provide more. Thank you for your help