【问题标题】:Geographically Instantiated model should face geographical head north地理实例化模型应面向地理方向北
【发布时间】:2020-10-16 05:27:31
【问题描述】:

我正在开发一个 android 应用程序,我将在其中放置基于地理位置的 3d 对象。这工作得很好。问题在于旋转,对象面向设备所面向的方向。我希望实例化的游戏对象面向地理北方向。我该怎么做? 我试过了

transform.rotation = Quaternion.Euler(0, -Input.compass.magneticHeading, 0);

它无法正常工作,显示方向错误。有没有其他方式游戏对象应该面向地理北方。

【问题讨论】:

  • 只是为了确定:您是否检查过Input.compass.enabled 设置为true

标签: c# android unity3d geolocation


【解决方案1】:

Afaik,您必须使用 Compass.enabled 之类的方式主动启用指南针

private void Awake ()
{
    Input.compass.enabled = true;
}

否则,您总是会得到最后检索到的值,默认情况下为 0,这会使您的对象生成面向 Unity 世界的正向 Z

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-16
    • 1970-01-01
    • 1970-01-01
    • 2011-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多