Question by
SamuelOliver123 · Jul 10, 2017 at 02:23 PM ·
scripting problemerrorgamescore
Negative Score
Hi ! I need a help. I make a score for the game,but when I finish make a scripts and play it, the score is not from 0 but from -4.
Here is the scripts :
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehaviour {
public Transform player;
public Text scoreText;
// Update is called once per frame
void Update () {
scoreText.text = player.position.z.ToString("0");
}
}
Can anyone help to solve this problem?
Thank You -Samuel-
Comment
The text shows "-4" when you expect it to show"0"?
This code just displays the z-coordinate of the object. If the number is "wrong", the object must not be in the position you think it is.