Set absolute rotation of GlobeAnchored actors in another sublevel

Hi,

my use case is maybe a bit complicated, I’ll try to describe it as simple as possible.

  1. I have several sublevels each with static meshes that have a Cesium Globe Anchor Component
  2. I am placing pins/markers (that have a Globe Anchor) on those static meshes during runtime
  3. The pins are rotated to point “outward” (i.e. the impact normal vector from a Line Trace)

  1. I have a custom built JSON save game format which contains (among other data) the transform of the player and the Lat/Long/Height coordinates as well as the transforms of the pins
  2. I’m “loading” the save game by going through the JSON and spawning the pins at their LatLong coordinates.

Now the problem: While setting their location is working, I don’t know how to save their rotation persistently and restore it if the pins are in a sublevel which is not the current Georeference origin.

Example workflow:

  1. Sublevel in Australia (just an example)
  2. I place a pin whose coordinates, transform etc are assigned to a variable in the pin-Blueprint
  3. FlyTo a sublevel in Germany, the georeference origin changes
  4. Place another pin
  5. Save to json, quit the game
  6. Restart the game
  7. Load from the json, which moves the player to their last location in Germany and spawns all the pins both in Australia and Germany
  8. The pins in the current sublevel (Germany) are rotated correctly
  9. If I fly to Australia, the pins will not be rotated correctly because the georeference origin at their spawn time was in Germany.

So the base line of my question is: How can I save and restore the absolute rotation of the pins that they had at their initial spawn even if I respawn them from “afar” (i.e. from another sublevel)

Interesting problem, thanks for sharing…

A couple follow up questions:

  • When you save a pin to json, what coordinates are you saving? (Unreal XYZ, ECEF, lat / long / height, etc)
  • When you load a pin at the start of the game, is its actor still under the LevelInstance that it was originally saved from?

I’m saving the Unreal Transform that I get from a simple Get Actor Transform node and the Lat/Long/Height coordinates.

I’m not sure about that but I also don’t know a lot about the Unreal Engine LevelInstance system yet.
Do actors that are spawned while being in a LevelInstance/Sublevel automatically “belong” to the level instance and not the persistent level? And what are the consequences of that?

I assume the pins I’m spawning are all placed in the persistent level. At least when I play in editor I can see that the pins/LocationMarkers are not under the LevelInstance in the world outliner.
I’m also not working with any Data Layers or anything like that

grafik

So the way I’m originally spawning the pin is by a simple SpawnActor node call that places it at the impact point of a line trace. So that initial location is an Unreal XYZ location.

Original Spawn call

When I’m loading the game from the save file, that spawn call currently looks like this. I use the saved LatLongHeight coordinates to calculate the Unreal location. The player pawn (a child class of the Globe Aware Default Pawn) location is set at the start of loading the game before the pins are respawned.

My current solution to that problem is that I have bound an event to On Georeference Updated that makes a pass through all pins/location markers returned by Get All Actors Of Class and updates their rotation when entering another sub level.

Simply put, I’m calling a function like “Snap Up to Ellipsoid Normal” (just that it snaps to the rotation from the save file) for all of the pins in the world when I’m flying to another location. It works but it’s not the most efficient solution and there’s always a short visible delay when the pins are snapping to their correct rotation.