前提
UnityでGoogleストリートビューを取り込み仮想旅行をすることができるものを作っています。
十字キーで道を行き来できる機能を実装しようとVector3を使い、latitudeとlongitudeの数値を増減させようとしています。
実現したいこと
十字キーで道を行き来すること。緯度経度の数字を十字キーで増減させたい。
本家Googleストリートビューのように道を進ませたい。
Vector3を使う前
発生している問題・エラーメッセージ
Assets\StreetViewImageLoader.cs(16,13): error CS0102: The type 'StreetViewImageLoader' already contains a definition for 'latitude' Assets\StreetViewImageLoader.cs(17,13): error CS0102: The type 'StreetViewImageLoader' already contains a definition for 'longitude'
該当のソースコード
C#
1using UnityEngine; 2using System.Collections; 3using UnityEngine.Networking; 4 5public class StreetViewImageLoader : MonoBehaviour 6{ 7 public double heading = 0.0; 8 public double pitch = 0.0; 9 10 private int width = 640; 11 private int height = 480; 12 13 private double latitude = 35.697408;//緯度 14 private double longitude = 139.667431;//経度 15 16 Vector3 latitude = Vector3.up; 17 Vector3 longitude = Vector3.up; 18 19 20 // Use this for initialization 21 void Start() 22 { 23 StartCoroutine(GetStreetViewImage(latitude, longitude, heading, pitch)); 24 Debug.Log("abc"); 25 26 } 27 28 private IEnumerator GetStreetViewImage(double latitude, double longitude, double heading, double pitch) 29 { 30 string url = "https://maps.googleapis.com/maps/api/streetview?key=【API key】&zoom=15&size=640x640&scale=2&maptype=terrain&style=element:labels|visibility:off" + "size=" + width + "x" + height + "&location=" + latitude + "," + longitude + "&heading=" + heading + "&pitch=" + pitch + "&fov=90&sensor=false"; 31 Debug.Log("def"); 32 33 UnityWebRequest www = UnityWebRequestTexture.GetTexture(url); 34 yield return www.SendWebRequest(); 35 36 var http_error = www.result == UnityWebRequest.Result.ProtocolError ? true : false; 37 var network_error = www.result == UnityWebRequest.Result.ConnectionError ? true : false; 38 if (http_error || network_error) 39 { 40 Debug.Log(www.error); 41 } 42 else 43 { 44 GetComponent<Renderer>().material.mainTexture = ((DownloadHandlerTexture)www.downloadHandler).texture; 45 } 46 } 47 // Update is called once per frame 48 //十字キー操作 49 void Update() 50 { 51 52 if (input.GetKey(KeyCode.UpArrow)) 53 { 54 transform.potision += latitude * Time.deltaTime; 55 } 56 if (input.GetKey(KeyCode.DownArrow)) 57 { 58 transform.potision -= latitude * Time.deltaTime; 59 } 60 if (input.GetKey(KeyCode.RightArrow)) 61 { 62 transform.potision += longitude * Time.deltaTime; 63 } 64 if (input.GetKey(KeyCode.LeftArrow)) 65 { 66 transform.potision -= longitude * Time.deltaTime; 67 } 68 } 69}
試したこと
上記のエラーが出た後に名称を変更したところCS1061・CS0103のエラーが出ました。
補足情報(FW/ツールのバージョンなど)
Visual Studio2019
Unity Hub 3.2.0
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/08/21 02:58