Score increasing in x position

Viewed 42

I am new to unity and c#. Currently I am going along with brackeys - how to make a video game series. But I am stuck at making the score board. I have copied the same code but don’t know why is it increasing when I am pressing w and s keys. Here is the code

using UnityEngine;
using UnityEngine.UI;

public class SCORE : MonoBehaviour
{
    public Transform player;
    public Text scoreText;

    void Update()
    {
        scoreText.text = player.position.x.ToString("0");
    }

}

Can someone point out the problem.

Thanks

1 Answers

The problem occurs here, scoreText.text = player.position.x.ToString("0"); You need to change it to scoreText.text = player.position.y.ToString("0"); so that the score increases when you are moving in forwards direction.

Related