简体   繁体   English

将地理坐标转换为Unity坐标系

[英]Transpose geographic coordinates to Unity coordinate system

I'm making a game that works only in a fixed geographical area. 我正在制作一款只能在固定地理区域内运行的游戏。 The custom I'm making the game for wants to a Pokémon Go-like user interface. 我为游戏制作的自定义项希望具有类似于PokémonGo的用户界面。 There will be a place with a custom image representing the geographical area I was taking about. 会有一个带有自定义图像的地方,该图像代表了我所乘的地理区域。 I successfully transposed the geographic coordinates to cartesian coordinate with the following code: 我使用以下代码成功将地理坐标转换为笛卡尔坐标:

cartesianCoord.x = EARTH_RADIUS * Mathf.Cos (location.latitude) * Mathf.Cos (location.longitude);
cartesianCoord.y = EARTH_RADIUS * Mathf.Cos (location.latitude) * Mathf.Sin (location.longitude);
cartesianCoord.z = EARTH_RADIUS * Mathf.Sin (location.latitude);

But now I can't properly place my character on the place. 但是现在我不能正确地放置角色了。 This represents my situation: (red dots are known) 这代表了我的情况:(已知红点)

The image on the left is my plane in Unity. 左图是我在Unity中的飞机。 How can I place the character in the right position on the plane? 如何将角色放置在飞机上的正确位置?

You should use linear interpolation. 您应该使用线性插值。

Mathf.Lerp documentation Mathf.Lerp文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM