I’m lost at what is going wrong here. Why isn’t my score writing out in the debug log correctly.
I see the “Hit” but my counter won’t increment.
using UnityEngine;
using System.Collections;
using System.Text;
using UnityEngine.UI;
public class MoveEnemy : MonoBehaviour {
//public GUIText Score;
public Text text;
public int scoreQty = 0;
public GameObject Player;
public float velocity = -1.0f;
void Start () {
//text = GetComponent <Text>();
}
// Update is called once per frame
void FixedUpdate () {
GetComponent<Rigidbody2D> ().velocity = -Vector2.right;
//GetComponent<Rigidbody2D>().velocity = new Vector2 (-velocity, GetComponent<Rigidbody2D>().velocity.y);
}
void OnTriggerEnter2D(Collider2D other){
if (other.gameObject.CompareTag ("Player")) {
Destroy (other.gameObject);
Debug.Log ("Hit");
Application.LoadLevel ("GameOver");
} else if (other.gameObject.CompareTag ("GivePointsBar")) {
Destroy (gameObject);
scoreQty = scoreQty+10;
Debug.Log (scoreQty);
Debug.Log("hit");
}
text.text ="Score:asdf "+scoreQty;
}
}
thanks for the help.