Привет. Я пытаюсь создать модель всегда в северном направлении. Как получить направление северного полюса в реальном мире.
public class PointNoeth : MonoBehaviour {
// Use this for initialization
//void Start ()
IEnumerator Start()
{
// First, check if user has location service enabled
if (!Input.location.isEnabledByUser)
yield break;
// Start service before querying location
Input.location.Start();
// Wait until service initializes
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
{
yield return new WaitForSeconds(1);
maxWait--;
}
// Service didn't initialize in 20 seconds
if (maxWait < 1)
{
print("Timed out");
yield break;
}
// Connection has failed
if (Input.location.status == LocationServiceStatus.Failed)
{
print("Unable to determine device location");
yield break;
}
else
{
// Access granted and location value could be retrieved
print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
}
// Stop service if there is no need to query location updates continuously
Input.location.Stop();
Input.compass.enabled = true;
}
// Update is called once per frame
void Update ()
{
transform.rotation = Quaternion.Euler(0, -Input.compass.trueHeading, 0);
/
}
}
В функции «Обновление» я установил поворот. Я сохранил метку стрелки в качестве моей модели. Сначала я держал ее указывающей в направлении z, но когда я нажимаю кнопку воспроизведения, она меняется на ось -x. То же самое происходит, когда я отмечаю Устройство. Когда я проверил, где на самом деле северный полюс, используя инструменты в моем телефоне, он находится в противоположном направлении. Так, как направить мою модель на северный полюс .