I’m programming a simple 2d game for android where you have to kill (destuir) objects that appear on the screen by touching them with your finger, then in my code the score is not working properly because the score increases as had destroyed all the objects in the game, and should be destroyed only assume as one
this is my code
using UnityEngine;
using System.Collections;
public class AddPoints : MonoBehaviour
{
void Update ()
{
if (Input.anyKeyDown)
{
PointScore.pointScore += 1f;
}
}
void OnMouseDown(){
Destroy (this.gameObject);
}
public float lifetime = 1.0f;
void Awake ()
{
Destroy(this, lifetime);
}
}
and
using UnityEngine;
using System.Collections;
public class PointScore : MonoBehaviour
{
public static float pointScore = 0;
void OnGUI ()
{
GUI.Label (new Rect (10, 10, 100, 20), "Score: " + pointScore);
}
}
if you can help I would be very grateful