From 83892f1712832426f1a01f457290f83988842da1 Mon Sep 17 00:00:00 2001 From: nexovec Date: Sat, 29 Jan 2022 19:13:21 +0100 Subject: [PATCH] imporved scoring --- Assets/Scripts/UiController.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/UiController.cs b/Assets/Scripts/UiController.cs index 0dbac46..5634f57 100644 --- a/Assets/Scripts/UiController.cs +++ b/Assets/Scripts/UiController.cs @@ -6,8 +6,7 @@ using TMPro; public class UiController : MonoBehaviour { public GameObject player = null; - private Vector3 startPosition; - private Vector3 playerPosition; + private float startPosition; public TextMeshProUGUI uiDistance; public float distance = 0.0f; private float oldDistance = 0.0f; @@ -15,7 +14,7 @@ public class UiController : MonoBehaviour // Start is called before the first frame update void Start() { - startPosition = this.player.transform.position; + startPosition = this.player.transform.position.z; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } @@ -23,8 +22,7 @@ public class UiController : MonoBehaviour // Update is called once per frame void Update() { - playerPosition = this.player.transform.position; - distance = Vector3.Distance(this.startPosition, this.playerPosition); + distance = this.player.transform.position.z - startPosition; if (oldDistance < distance) { uiDistance.text = "Distance : " + distance.ToString("0");