前提・実現したいこと
Unityで旗と車の距離を表示するUIを作っています。
ここに質問の内容を詳しく書いてください。
初学者初質問です。
ソースコードの下から3行目あたりでエラーが出ます。
UIのスクリプトで旗(flag)と車(car)の距離(distance)を表示しようとしています。
assembly referenceの記事を読んだりやコードの打ち間違えを考えましたがさっぱりわかりませんでした。
どこか設定が悪いのでしょうか?
出来るだけ詳細に教えていただけるとありがたいです。よろしくお願いします
発生している問題・エラーメッセージ
Assets/GameDirector.cs(24,28): error CS1061: 'Transform' does not contain a definition for 'positon' and no accessible extension method 'positon' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)
エラーメッセージ
該当のソースコード
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameDirector : MonoBehaviour
{
GameObject car;
GameObject flag;
GameObject distance;
// Start is called before the first frame update
void Start()
{
this.car = GameObject.Find("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.positon.x; this.distance.GetComponent<Text>().text = "ゴールまで"+length.ToString("F2")+"m";
ソースコード
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/08/14 06:50