# Position offset of LineRenderer

**URL:** <https://community.cesium.com/t/position-offset-of-linerenderer/28634>\
**Category:** Cesium for Unity\
**Created:** [December 11, 2023, 7:34am UTC](https://community.cesium.com/t/position-offset-of-linerenderer/28634 "2023-12-11T07:34:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Huangyanpeng](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/huangyanpeng/32/14000_2.png) [@Huangyanpeng](https://community.cesium.com/u/Huangyanpeng)\
**Post date:** [December 11, 2023, 7:34am UTC](https://community.cesium.com/t/position-offset-of-linerenderer/28634/1 "2023-12-11T07:34:17Z")

</div>

I use LineRenderer to render polygon curves.The data is multipolygon in the wgs84 coordinate system (srid=4326).  
(1)  
I use a multipolygon data a to create a gameobject and add a LineRenderer component.  
Use the following two lines of code to convert latitude and longitude coordinates into unity world coordinates, and the rendering result is located correctly;  
double3 db3 = new double3();  
db3.x = longitude;  
db3.y = latitude;  
db3.z = 5000;  
double3 ecef = CesiumWgs84Ellipsoid.LongitudeLatitudeHeightToEarthCenteredEarthFixed(db3);  
double3 xyz = m\_CesiumRoot.TransformEarthCenteredEarthFixedPositionToUnity(ecef);  
Vector3 v3 = new Vector3((float)(xyz.x), (float)(xyz.y), (float)(xyz.z));  
(2)  
I used multiple multipalygon data for rendering, created multiple gameobjects, and multiple LineRenderer components.  
One of the data was consistent with the first debugging data a, and the same coordinate conversion code was used.  
However, the world coordinates of Unity after latitude and longitude conversion changed, and the position of Unity’s rendering results also shifted.  
What is the reason and how should I solve it

---

<div class="post-metadata">

**Author:** ![janine](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/janine/32/5135_2.png) [@janine](https://community.cesium.com/u/janine)\
**Post date:** [December 11, 2023, 5:01pm UTC](https://community.cesium.com/t/position-offset-of-linerenderer/28634/2 "2023-12-11T17:01:56Z")

</div>

Does your camera have a `CesiumOriginShift` component attached? If so, the Unity origin will shift every time the camera moves. You may want to remove or disable this for your purposes.

---

<div class="post-metadata">

**Author:** ![Huangyanpeng](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/huangyanpeng/32/14000_2.png) [@Huangyanpeng](https://community.cesium.com/u/Huangyanpeng)\
**Post date:** [December 12, 2023, 1:59am UTC](https://community.cesium.com/t/position-offset-of-linerenderer/28634/3 "2023-12-12T01:59:03Z")

</div>

First of all, thank you for your help.In this project, I added a dynamic camera to view polygons from any perspective.  
To ensure that the rendered object moves synchronously with the camera’s zoom in, zoom out, and pan operations,  
I added a component CesiumOriginShift to each newly created GameObject,code like this:  
GameObject line\_ = new GameObject(“Line”);  
line\_.transform.parent = m\_CesiumRoot.transform;  
line\_.transform.position = vertices[0];  
line\_.AddComponent();  
line\_.AddComponent();  
line\_.AddComponent();  
if i do not add CesiumOriginShift,the rendered polygon curves are not moving with the dynamic camera.  
I want to place the polygonal curve at a fixed world coordinate position,and move it with the dynamic camera,  
but the position of a polygon is correct in unity, but the positions of multiple polygons are offset,Like the following two pictures,  
two identical polygons with different positions in LineRenderer rendering debugging,what’s the problem?

 ![first](https://global.discourse-cdn.com/cesium/original/3X/a/5/a56bfbf0eeceaea1fedef720b2c471b0cacb24f6.jpeg)  
 ![second](https://global.discourse-cdn.com/cesium/original/3X/9/c/9c673123f4218281f5550efbedb148720c5df5db.jpeg)

---

<div class="post-metadata">

**Author:** ![janine](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/janine/32/5135_2.png) [@janine](https://community.cesium.com/u/janine)\
**Post date:** [December 12, 2023, 4:28pm UTC](https://community.cesium.com/t/position-offset-of-linerenderer/28634/4 "2023-12-12T16:28:27Z")

</div>

You don’t want to add a `CesiumOriginShift` to multiple stationary objects. The `CesiumOriginShift` component should be attached to a GameObject that moves – for example, a camera or character. When that `GameObject` moves, the origin will be shifted with it.

It sounds like you should use `CesiumGlobeAnchor` components instead. When attached to a `GameObject`, the component will “anchor” it to that precise location on the Earth. This will automatically account for origin shifting.

---

<div class="post-metadata">

**Author:** ![Huangyanpeng](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/huangyanpeng/32/14000_2.png) [@Huangyanpeng](https://community.cesium.com/u/Huangyanpeng)\
**Post date:** [December 13, 2023, 1:28am UTC](https://community.cesium.com/t/position-offset-of-linerenderer/28634/5 "2023-12-13T01:28:18Z")

</div>

Thank you for you help.  
This problem has been solved when i add a component CesiumOriginShift to the dynamic camera,and remove the component CesiumOriginShift of the newly created gameObject and add a component CesiumGlobeAnchor to the the newly created gameObject.  
Thank you very much again.
