RtkPos.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class RtkPos : MonoBehaviour
  5. {
  6. /// <summary>
  7. /// 显示物体
  8. /// </summary>
  9. public List<Transform> list_Obj;
  10. /// <summary>
  11. /// 根据实地GPS数据转化位置信息 ( 与 List_Obj 对应)
  12. /// </summary>
  13. public List<Vector2> list_Pos;
  14. /// <summary>
  15. /// 根据玩家传输进来的Gps 推算出 物体位置
  16. /// </summary>
  17. /// <param name="playerGps"></param>
  18. public void SettingPos( Vector2 playerGps )
  19. {
  20. if(list_Pos.Count!=list_Obj.Count)
  21. {
  22. Debug.LogError(" RTK版本 提供的物体和提供的坐标数量不符 ");
  23. return;
  24. }
  25. for (int i = 0; i < list_Obj.Count; i++)
  26. {
  27. Vector2 diff = list_Pos[i] - playerGps;
  28. Vector3 playerPos = API_SVR.GetHead().position;
  29. Vector3 pos = new Vector3(playerPos.x + diff.x, 0, playerPos.z + diff.y);
  30. list_Obj[i].position = pos;
  31. }
  32. }
  33. }