Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; // UI部品を使用するために必要
public class GameDirector : MonoBehaviour {
GameObject car;
GameObject flag;
GameObject distance;
// Use this for initialization
void Start () { = GameObject.Find ("car"); // このように記載することでプロジェクト内のcarオブジェクトを見つけることができる
this.flag = GameObject.Find("flag");
this.distance = GameObject.Find("Distance");
// Update is called once per frame
void Update () {
float length = this.flag.transform.position.x -;
this.distance.GetComponent<Text> ().text = "ゴールまで" + length.ToString ("F2") + "m";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.