I have two scripts, one which control my guiText on screen and another which handles the bull of the firing mechanics.
What i would like is to increase my score every time i destroy an enemy but as of now it happens every time i fire. Anyone able to help me out?
Here is some of my cannon script:
if (Input.GetButtonDown("Fire1"))
{
Rigidbody clone;
clone = Instantiate(projectile, transform.position + offset, transform.rotation) as Rigidbody;
clone.velocity = transform.TransformDirection(Vector3.forward * force);
if(clone.gameObject.tag == "bullet")
{
Destroy(clone.gameObject, destroyTime);
//I want to add score here
accelShotHS.score += 1;
}
}
Here is the GUIText script:
public class accelShotHS : MonoBehaviour
{
public static int score;
public GUIText text;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
guiText.text = "Score: " + score;
}
}