My game is a round maze where you need to roll the ball to the center. I need to create a score system ( i guess with gui text ) of how many times overall player hits the center with the ball. But i don’t know what i am doing wrong in my code…
using UnityEngine;
using System.Collections;
public class Reset2 : MonoBehaviour {
private int Score = 0;
public GUIText MaxScore; //and yes i've dragged created gui text into empty field//
private GameObject[] Wally;
private Vector3 initialPosition;
private float distance = 0.5f;
void Start () {
initialPosition = transform.position;
}
void Update () {
transform.Translate(Vector3.zero * Time.deltaTime);
if( Vector3.Distance(transform.position, Vector3.zero) < distance)
{
transform.position = initialPosition;
Application.LoadLevel(Application.loadedLevel);
Score++; //i've tried "Score = 1;" too//
MaxScore.text=" " + Score; //Gui text is empty///
}
}
}