# Origin shifting, problems with UI

**URL:** <https://community.cesium.com/t/origin-shifting-problems-with-ui/25369>\
**Category:** Cesium for Unity\
**Created:** [July 13, 2023, 5:48pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369 "2023-07-13T17:48:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 13, 2023, 5:48pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/1 "2023-07-13T17:48:29Z")

</div>

I have an issue with my UI screen, it stops working when I move away from the center of origin. And I don’t even have to go too far for it to stop working. I followed direction in this article, and added origin shifting. [Placing Objects on the Globe – Cesium](https://cesium.com/learn/unity/unity-placing-objects/).

Here it says " Automatic origin shifting can be enabled by adding the **CesiumOriginShift** component to the main camera."

And then it says " The camera should be parented by a game object containing a **CesiumGeoreference** component." Can you please explain that part, because when I parent camera to anything that has CesiumGeoreference component, it does not behave well.  
The main screen that I need to work is my main way for people to explore the world, and I need it to work well no matter how far they travel. I tried adding “global anchor” to the main UI screen, but it didn’t make a difference.

Thanks, Evgeniya

![ezgif.com-video-to-gif (1)](https://global.discourse-cdn.com/cesium/original/2X/f/ff5bfc26870987b4403e283091a52a3306a83240.gif)

 ![Screenshot 2023-07-13 133912](https://global.discourse-cdn.com/cesium/original/2X/9/9eaeb840c2d8d2bf58590f5e7c9ef19424c1be4d.jpeg)  
 ![OriginShift](https://global.discourse-cdn.com/cesium/original/2X/c/cf7c61c67a10aba8f2b0ec2d5449c926803f749e.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:** [July 13, 2023, 9:14pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/2 "2023-07-13T21:14:13Z")

</div>

Anything with a `CesiumGlobeAnchor` _has_ to be parented by a `CesiumGeoreference`, or else it won’t keep track of its global state. Your screenshots show that your globe-anchored objects aren’t underneath the `CesiumGeoreference`.

> And then it says " The camera should be parented by a game object containing a **CesiumGeoreference** component." Can you please explain that part, because when I parent camera to anything that has CesiumGeoreference component, it does not behave well.

What part of isn’t “behaving well”?

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 14, 2023, 11:55am UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/3 "2023-07-14T11:55:02Z")

</div>

The main bug is that the avatar is locked in place when I put it under Cesium georeference. However, it goes away when I do “build and run” a second time without changing anything. But the UI screen stops working anyway just a few meters away from the origin. I went around all of the UI elements to make sure Main camera is attached to the canvas, and that all UI elements have Mesh Rendered. Still does not work, and I get a ton of warning messages.

Evgeniya

 ![CesiumWarning](https://global.discourse-cdn.com/cesium/original/2X/8/8e9c6cebe109b5ed4c2084c43b2a8303048c0a4b.png)

 ![CesiumWarnings2](https://global.discourse-cdn.com/cesium/original/2X/b/b1f6f9d28364ef54b702c4765b7f137635283f57.png)

---

<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:** [July 14, 2023, 3:21pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/4 "2023-07-14T15:21:20Z")

</div>

Okay, let’s back up. Can you describe what you _want_ your UI to do? The components you’re using don’t seem to be helping you with that.

> The main bug is that the avatar is locked in place when I put it under Cesium georeference.

Assuming the “avatar” contains a `CesiumGlobeAnchor` component, this is supposed to happen. A `CesiumGlobeAnchor` “anchors” the object to a specific location on the globe. So if you want an object to stay at a specific point (e.g., a model of a building at a certain location), you can use a `CesiumGlobeAnchor` to “anchor” that object to the globe. You _can_ move the object still, but you’d have to program the movement yourself. In other words, if you just drag the `CesiumGlobeAnchor` onto your object and do nothing else, it’s not going to move with you when you move away.

From what I could infer from the short description, it sounds like you need the UI to follow the user when they walk away. But I can’t tell what you want that to look like. Is it supposed to literally follow the user as they walk? Or is the UI supposed to stay at the location the user activates it?

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 15, 2023, 11:08am UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/5 "2023-07-15T11:08:04Z")

</div>

@joseph.kaile Do you think you can help me here? I run a bunch of tests, here are the issues that come up:

1. When I place XR origin under “Cesium Georeference” I have two types of bugs that go away after I click “build and run” 2-3 times.

- I am either locked in place and can’t move
- Terrain is flying away.

1. I made 3 copies of the same UI screen. The first one has no globe anchors attached, and works only within a certain perimeter. The second one has Globe anchor attached to the parent object only. As you can see the screen exhibit jittering, but still works, stops working outside of a certain perimeter. The third UI has Globe anchor elements attached to all of the children object, and they have disappeared in play mode, and the position of UI screen also changed.  
Any tips how to fix that?

Thanks, Evgeniya  
 ![CesiumUIProblems](https://global.discourse-cdn.com/cesium/original/3X/0/3/03b43580214e1ce6ebbf75ec8a826cf7e1d2afc5.gif)

---

<div class="post-metadata">

**Author:** ![joseph.kaile](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/joseph.kaile/32/3476_2.png) [@joseph.kaile](https://community.cesium.com/u/joseph.kaile)\
**Post date:** [July 15, 2023, 12:43pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/6 "2023-07-15T12:43:45Z")

</div>

Hello @VRTravelExpo,

In regard to the first problem,

I suggest adding the “CesiumOriginShift” script to the XR origin GameObject. When you attach this script, it also automatically attaches a Cesium Globe Anchor script as well.

For reference, I also set up a scene with the XR origin under a Georeference here ( [Add sample scene for dynamic camera in VR by joseph-kaile · Pull Request #62 · CesiumGS/cesium-unity-samples (github.com)](https://github.com/CesiumGS/cesium-unity-samples/pull/62)).

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 15, 2023, 4:26pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/7 "2023-07-15T16:26:00Z")

</div>

Thanks for sharing this, I inspected your scene, and made some adjustments in mine. Added Origin Shift to the XR Origin instead of the Main Camera. However, the UI that that is further away still does not work. They both have Globe Anchor attached to the parent object. The one which is closer works fine. I tried again attaching Globe Anchors to each child object, but all UI elements vanished, only screen mesh is left standing as seen above.

 ![CesiumUIProblems](https://global.discourse-cdn.com/cesium/original/2X/2/2a7485f137c9436c033a6daa31c7025476a7ef3c.jpeg)

---

<div class="post-metadata">

**Author:** ![joseph.kaile](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/joseph.kaile/32/3476_2.png) [@joseph.kaile](https://community.cesium.com/u/joseph.kaile)\
**Post date:** [July 15, 2023, 5:14pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/8 "2023-07-15T17:14:41Z")

</div>

OK, first I do not think adding Globe Anhors to each child object should be necessary.

Secondly, if the UI starts flickering that seems that the UI is far from the origin.

I tested this in my scene:

I added a UI Canvas and placed it far away from the origin. I also added a Globe Anchor to the root object (Canvas):

 ![image](https://global.discourse-cdn.com/cesium/original/2X/9/9771d65ed1abff706182a4712151f28f61eebe1b.png)

Its position relative to the camera is:  
(-11911.94, -227.1545, 34104.79).  
I wouldn’t expect this to work with these coordinates.

When I zoom up to the canvas, the position shrinks to something smaller:

 ![image](https://global.discourse-cdn.com/cesium/original/2X/7/7ee7e67d97c3d76e46d3fed3849a564c8cac76b8.png)

Could you verify that the canvas transform values get to these relatively small values?

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 15, 2023, 5:39pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/9 "2023-07-15T17:39:19Z")

</div>

My Main\_Screen transform values are very small. The one which stops working is only 74 meters away from the origin. Also, not sure if that matters, but my UI is very complex, the parent is a mesh and all of the elements, including the canvas and UI buttons are nested. They all have different original transform values, which were adjusted to fit the current UI. I can try finding root Canvas objects, but I have several of them under one UI screen.

 ![UI01](https://global.discourse-cdn.com/cesium/original/2X/5/50a2e9531d7c934fb0e3e70d067265049d2c4e9e.jpeg)

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 15, 2023, 5:52pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/10 "2023-07-15T17:52:32Z")

</div>

This screenshot does not show Globe Anchor attached, because I was experimenting placing it to child objects, but I did try all ways.

---

<div class="post-metadata">

**Author:** ![joseph.kaile](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/joseph.kaile/32/3476_2.png) [@joseph.kaile](https://community.cesium.com/u/joseph.kaile)\
**Post date:** [July 15, 2023, 6:03pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/11 "2023-07-15T18:03:25Z")

</div>

Im trying to recreate the same UI setup.

I have a gameobject with a Globeanchor attached to it. I also have 4 Canvas’ with 4 different types of UI elements attached. It worked as expected.

Maybe this will work:

Putting the MiddleScreen\_03 gameobject underneath a blank GameObject. And then attaching a globe anchor to that blank GameObject.

Do you also see this problem using the XR device simulator?

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 15, 2023, 6:17pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/12 "2023-07-15T18:17:49Z")

</div>

No, I am only testing in the headset. Let me start from scratch, and see if I can get the basic UI working and then move my elements there separately. I’ll get back to you.

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 15, 2023, 9:39pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/13 "2023-07-15T21:39:41Z")

</div>

So, I tested a brand new scene and two super simple UIs - one with the parent GameObject and Canvas underneath it, and another one just the Canvas (both parents with Globe anchor). As before, the nearest button works, and the farthest don’t. Its as if the buttons don’t exist in the space at all, Ray Interactor just passes through them like there is nothing in that space. I know my users will want to venture off and explore terrains, and there will be no way for them to get out of that scene if I don’t get this working. It is probably difficult for you to test it with the device simulator, cause you have to teleport pretty far away from where you landed.

Thank you so much for your help, Evgeniya

---

<div class="post-metadata">

**Author:** ![joseph.kaile](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/joseph.kaile/32/3476_2.png) [@joseph.kaile](https://community.cesium.com/u/joseph.kaile)\
**Post date:** [July 15, 2023, 10:32pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/14 "2023-07-15T22:32:43Z")

</div>

I put a button on the opposite side of the Denver sample map and it worked. Maybe there are some settings that is making the Ray interactor not work properly?

I set the Max Raycast distance pretty far in order to teleport faster.

 ![image](https://global.discourse-cdn.com/cesium/original/2X/4/4837c46fe9e823615f22c329be393dd6ce09c42e.png)

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 16, 2023, 10:58am UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/15 "2023-07-16T10:58:48Z")

</div>

That value is too big, it will be hitting unwanted targets. But I was doing more tests with the device simulator, and I can confirm the behavior is exactly the same as in the headset. The button works fine once you first enter the game. And it appears there is no difference how far the buttons are located. The problem is with XR origin’s position, once it gets closer to the buttons - or farther away from where it landed, the buttons stop registering. And it appears there is no difference if XR origin is close to Georeference center point or not on start; I moved it far away from it and the behavior was still the same. I tested it in my other scenes without Cesium components, and no matter how far I go UI elements work no problem. So there is something internally that is shutting down the buttons with avatar’s travelling distance. Maybe origin anchor script does not recognize UI buttons?  
 ![ezgif.com-video-to-gif (2)](https://global.discourse-cdn.com/cesium/original/2X/e/e6da3dd3b3e0a3e1badde37c680c5c946cac3485.gif)

---

<div class="post-metadata">

**Author:** ![joseph.kaile](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/joseph.kaile/32/3476_2.png) [@joseph.kaile](https://community.cesium.com/u/joseph.kaile)\
**Post date:** [July 16, 2023, 1:31pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/16 "2023-07-16T13:31:32Z")

</div>

Interesting, I’m wondering if after you go a certain distance, all the buttons start working…

This is very mysterious. It seems to only be happening in your projects. Is there a way I could get a very simple Unity project that has this problem that I could reproduce on my end?

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 16, 2023, 1:52pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/17 "2023-07-16T13:52:53Z")

</div>

I am using XR Origin set up from this project, but I updated the project to the latest Unity 2022.3.4f1.

> **[GitHub - Unity-Technologies/XR-Interaction-Toolkit-Examples: This repository...](https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples)**
>
> This repository contains various examples to use with the XR Interaction Toolkit - GitHub - Unity-Technologies/XR-Interaction-Toolkit-Examples: This repository contains various examples to use with...

I can try setting up my own rig from scratch using the input system, my only concern is that this rig works fine in every other regular scene, so something is conflicting specifically with Cesium. I know a lot of developers like to start with this project because it has a lot of pre built functionality and prefabs.

Evgeniya

---

<div class="post-metadata">

**Author:** ![joseph.kaile](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/joseph.kaile/32/3476_2.png) [@joseph.kaile](https://community.cesium.com/u/joseph.kaile)\
**Post date:** [July 17, 2023, 11:03pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/18 "2023-07-17T23:03:46Z")

</div>

I just tried setting up a quick scene using the above Project. However I couldn’t get the button to stop working. Are you using the latest version of Cesium for Unity?

---

<div class="post-metadata">

**Author:** ![VRTravelExpo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/vrtravelexpo/32/12437_2.png) [@VRTravelExpo](https://community.cesium.com/u/VRTravelExpo)\
**Post date:** [July 17, 2023, 11:37pm UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/19 "2023-07-17T23:37:56Z")

</div>

Yes, was using the latest one, but I will try to re-install it.

---

<div class="post-metadata">

**Author:** ![joseph.kaile](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/joseph.kaile/32/3476_2.png) [@joseph.kaile](https://community.cesium.com/u/joseph.kaile)\
**Post date:** [July 18, 2023, 12:00am UTC](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369/20 "2023-07-18T00:00:39Z")

</div>

I recall there is an issue that was made about Origin Shift and XR:

[Origin Shifting and XR bug · Issue #168 · CesiumGS/cesium-unity (github.com)](https://github.com/CesiumGS/cesium-unity/issues/168)

It doesn’t suprise me that Bad Things happen when the Cesium Origin Shift is attached directly to the camera.

Could you confirm to me that you only have the Origin Shift script attached to the GameObject highlighted below?  
 ![image](https://global.discourse-cdn.com/cesium/original/2X/d/d8b97aac32fa6dea7e859080af71340952db5f69.png)

[Next page](https://community.cesium.com/t/origin-shifting-problems-with-ui/25369.md?page=2)
