UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"distance to checkpoint"
public class DistanceToCheckpoint : MonoBehaviour { [SerializeField] private Transform checkpoint; [SerializeField] private Text distanceText; private float distance; private void Update () { distance = (checkpoint.transform.position.x - transform.position.x); distanceText.text = "Distance: " distance.ToString("F1") " meters"; if (distance <= 0) { distanceText.text = "Finish!"; } } }