i have made a project with unity where i use my mouse to click on an archery target. for that i made a counting script that gives me points when i click the target.
my problem is that when i click it counts to much points. can enyone help me out?
i also need to place a cross where i clicked and that has to disapear after 1min. but i don’t know how to do it.
any idees?
counting script:
`using UnityEngine;
using System.Collections;
public class Count : MonoBehaviour
{
public bool isClicked = false;
public GUIText countText;
private int count;
public void Start()
{
count = 0;
SetCountText ();
if(gameObject.GetComponent<Collider> () == null)
gameObject.AddComponent<BoxCollider> ();
}
public void OnMouseDown()
{
isClicked = true;
}
public void OnMouseUp()
{
isClicked = false;
}
public void OnGUI()
{
if (isClicked)
{
GUI.Label (new Rect (5, 5, 400, 100), " This is " + this.name);
count = count + 1;
SetCountText ();
}
}
void SetCountText ()
{
countText.text = "Count: " + count.ToString ();
}
}
`