I have no idea what’s going on here. First unity tells me I need to add an extra curly bracket at the end but when I do I still get an error. Hope You Can find the problem.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float Speed;
public GUIText countText;
public GUIText winText;
public GUIText Failtext;
public int EnemyHits;
private int count;
void Start ()
{
count = 0;
SetCountText ();
winText.text = "";
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * Speed * Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "PickUp")
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText ();
}
else if (other.gameObject.tag == "EnemyPickUp")
{
other.gameObject.SetActive(false);
EnemyHits = EnemyHits + 1;
SetCountText ();
}
}
void ChangeScene ()
{
if (winText.text == ("Level Cleared!"))
Application.LoadLevel("LevelCleared");
}
void SetcountText ()
{
countText.text = "Count: " + count.ToString ();
{
if(count >= 5)
{
winText.text = "Level Cleared!";
Application.LoadLevel("LevelCleared");
}
else if(EnemyHits >= 2)
{
winText.text = "Level Failed";
Application.LoadLevel("Fastgame2");
}