imporved scoring
This commit is contained in:
parent
80c944f6b0
commit
83892f1712
@ -6,8 +6,7 @@ using TMPro;
|
|||||||
public class UiController : MonoBehaviour
|
public class UiController : MonoBehaviour
|
||||||
{
|
{
|
||||||
public GameObject player = null;
|
public GameObject player = null;
|
||||||
private Vector3 startPosition;
|
private float startPosition;
|
||||||
private Vector3 playerPosition;
|
|
||||||
public TextMeshProUGUI uiDistance;
|
public TextMeshProUGUI uiDistance;
|
||||||
public float distance = 0.0f;
|
public float distance = 0.0f;
|
||||||
private float oldDistance = 0.0f;
|
private float oldDistance = 0.0f;
|
||||||
@ -15,7 +14,7 @@ public class UiController : MonoBehaviour
|
|||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
startPosition = this.player.transform.position;
|
startPosition = this.player.transform.position.z;
|
||||||
Cursor.lockState = CursorLockMode.None;
|
Cursor.lockState = CursorLockMode.None;
|
||||||
Cursor.visible = true;
|
Cursor.visible = true;
|
||||||
}
|
}
|
||||||
@ -23,8 +22,7 @@ public class UiController : MonoBehaviour
|
|||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
playerPosition = this.player.transform.position;
|
distance = this.player.transform.position.z - startPosition;
|
||||||
distance = Vector3.Distance(this.startPosition, this.playerPosition);
|
|
||||||
if (oldDistance < distance)
|
if (oldDistance < distance)
|
||||||
{
|
{
|
||||||
uiDistance.text = "Distance : " + distance.ToString("0");
|
uiDistance.text = "Distance : " + distance.ToString("0");
|
||||||
|
Loading…
Reference in New Issue
Block a user