I try to make a score that is related to the distance my Character is moving. Its made in 2D.
My Character ist moving at a constant speed and i want do add 1 to score the every time my Character moves 1 one the x coordinate forward(to the right).
So far i only got a little bit of code where the score gets +1 on every FixedUpdate and that works but its not what i try do to. I thought on something with comparing transform.position but im not sure how to do that.
public Text scoreText;
public Vector3 position;
void Start()
{
score = 0;
}
void FixedUpdate()
{
if (isRunning)
{
Debug.Log("X-Coordinate = " + transform.position.x.ToString());
scoreText.text = score++.ToString();
}
}