using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class playerController : MonoBehaviour {
public float speed = 20;
public Text countText;
private int count;
private bool isPressed = false;
void Start()
{
count = 0;
countText.text = "Score: " + count.ToString ();
}
void Update()
{
var move = new Vector3 (Input.GetAxis ("Horizontal"), 0, 0);
transform.position += move * speed * Time.deltaTime;
}
void OnCollisionEnter(Collision col) {
if (col.gameObject.name == "crate1") {
Destroy(col.gameObject);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (this.isPressed = false)
{
other.gameObject.SetActive(false);
count = count + 1;
}
}
}
I have this code right here. When ever I click a button called “YES”, I want the score to increase by 1, but I don’t know how to implement it into my code. How can I do it?