Created
August 18, 2019 09:47
-
-
Save adash333/7c5c2b1e963d08a56c8e26b5c569369b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () { | |
this.car = 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.car.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