How to make the view follow earth when moving in c++

I’ve copy the globeawaredefultpawn code about the moving,moving is normal but the orientation didn’t work as the dynamic pawn when moving right to make the earth always display in the center of the screen

You’ll need to share what you’ve done in more detail in order for us to be able to help you.

I try the sample with DynamicPawn and it works,but the pawn seems move far away from the earth while keeping moving.After reading the cpp of GlobeAwareDefaultPawn,still can not find out how to solve it,

The dynamic pawn flying strangely is usually caused by “Enable World Bounds Check” in your World Settings. Disable it.

Recent versions of Cesium for Unreal add a warning to the Output Log to inform you of this, but it’s easy to miss.

Thanks sir,I’ve checked it was closed,and found it normal when I wrote the “set georeference origin here” code in the tick function.It seems that the reason for moving away from Earth is due to curvature deviation or other factors caused by deviation from or away from the origin?

Sorry, but I’m having a little trouble parsing what you’re saying.

The DynamicPawn accounts for globe curvature. It may drift a little outward with fast and repeated movement, but the effect should be small. Let me explain.

Let’s say you’re holding down the “D” key to make the pawn move to the right. The direction of “right” is computed based on a local horizontal coordinate system centered at the pawn’s current location. If you imagine extending this vector out to infinity, the globe surface will of course fall away under it. This vector is recomputed every frame, though, and then the pawn is moved the appropriate distance along that vector for the frame. If you’re moving a long way in a single frame (because the pawn’s movement speed is very high, for example, or perhaps the frame rate is very low), then that direction vector, extended out by the travel distance, will have a bit of error. The pawn will gain a very tiny amount of altitude during the movement. Over multiple frames, this can add up and cause the pawn to drift away from the surface.

I think you’d struggle to even notice this in most applications. But if it’s a problem in yours (again, because of extremely high movement speed or low frame rate), you could reset the height after each movement of the pawn that isn’t supposed to change the height. Get the current longitude / latitude / height, move the pawn to the right, get the new longitude / latitude / height, set the pawn position to the new longitude / latitude but the old height.

Thanks,it helps me a I’m trying to navigate with mouse with learning the globalawaredefaultpawn,one of the challenge is the mouse rate just not like the key go,it will move fast or slow some time while using and grab somewhere to move also no as easy as cesiumjs…I’ve view some here and github,would like to know any info about the mouse navigator.

Hi @ZhengYongHe,

GlobeAwareDefaultPawn just builds on top of Unreal’s DefaultPawn, which comes with built-in controls. I would suggest looking at the DefaultPawn controls; you may have to override them yourself if you are unsatisfied with the setup.

Hello janine, if my camera inherits the GlobeAwareDefaultPawn, but I need an observer’s pawn, so I add a spring arm, and then drag the mouse to achieve displacement, of course, I did not modify the earth curvature algorithm, because I do not understand it. Therefore, I can’t see the earth when I move. Is there any good solution for this