Click here to Skip to main content
15,888,155 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey,

I am working on a game and trying to display the distance covered as the score. But despite the code written and debugged, the score is rising when I am moving to escape the obstacles. I want the score to increase according to the distance covered(in meters). And also I want the score to increase towards the x axis.

Here is the code that I have written.

using UnityEngine;
using UnityEngine.UI;

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

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

}


What I have tried:

I have tried modifying the code as in the x axis in spite of y axis. Please help.
Posted
Updated 28-May-21 5:39am

1 solution

X axis, Y axis - neither will help.
Try some of these: unity distance traveled - Google Search[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900