Hello
i need your help guys,
i want to compare a position of two gameobjects and if there equal, the score +1
this is my code .the problem that i always have a “0” for the score
void Update () {
transform.Translate(Vector3.right * Input.GetAxis("Horizontal") * Time.deltaTime * 40);
transform.Translate(Vector3.forward * Input.GetAxis("Vertical") * Time.deltaTime * 40);
tmpPo = transform.position;
tmpPo2 = cube1.transform.position;
if ((Mathf.Approximately(tmpPo.x,tmpPo2.x))) //& (Mathf.Approximately(tmpPo.z, tmpPo2.z)))
{
sc++;
}
Text singleText = mytext1.GetComponentInChildren<Text>();
singleText.text = "tmp: " + tmpPo + " tmp2: "+ tmpPo2;
Text singleText2 = mytext2.GetComponentInChildren<Text>();
singleText2.text = "score: " + sc;
}