Which Unique ID or Name will work in packaged game

I’m confused about which of these works in only the editor and which will work in the packaged game. I have SaveGames files that keep checkpoints for all my level objects that are marked with a GetName() for the world object. These are how I poke in the values from the checkpoints to update the world placed objects on a reload of the level. On a level reload, I iterate the world Actors and match up the GetName() to the checkpoint entries. I was naively using the GetName() as a unique key.

I read in an answers thread, that GetName() would work only in the editor, but not work in the packaged game, which would mean my save method will fail. I can’t currently package to test this because of blueprint errors the modeler is working on, so I did some testing to see if there were other unique IDs or Names that might be used as a key to the world object in my checkpoint file. I’ve tried these:

GetName()
GetUniqueID()
UKismetSystemLIbrary::GetObjectName(*UObject)

If, as the thread I read said, GetName() will not function in the packaged game, the other two options sounded promising. The GetUniqueID() seems to return an id number that isn’t consistent from one reload to the next even though it is nice and unique. Sometimes the number it returns matches the number it returns on a reload of the level, but every 4th time or so, it doesn’t return a consistent number for a given world object (i.e., on reload, it will have a different set of unique numbers). I tried the GetObjectName(*UObject) and it does appear to return a consistent unique name for world objects (indeed, identical to GetName()), but I need to verify that it will work in a packaged game, or if it too is not to be used outside the editor.

First, is the GetName() non-functional in a packaged game? If so, is the GetObjectName useful for identifying a world object in the level across reloads when the game is packaged? Is there some other way to consistently and uniquely match up these world objects that will survive load and reload?

Here are some example log entries of objects placed in the world. I display the GetName(), the GetUniqueID() and the GetObjectName() at the end of each line. Note that the Unique ID just happens to have stayed consistent between initial load and reload, but that is not always the case. This was running in the editor, I don’t know what these would look like if it were run in a packaged game.

Initial Load of level:
LogTemp: Warning: InitialLevelLoad: Will be reloading this as BoxToStartMissions 116072 BoxToStartMissions
LogTemp: Warning: InitialLevelLoad: Will be reloading this as FMCIntel_Pickup_2 116070 FMCIntel_Pickup_2
LogTemp: Warning: InitialLevelLoad: Will be reloading this as ImpactWrench_Pickup_2 116068 ImpactWrench_Pickup_2
LogTemp: Warning: InitialLevelLoad: Will be reloading this as BP_ContainerBase_2 116067 BP_ContainerBase_2
LogTemp: Warning: InitialLevelLoad: Will be reloading this as BP_ContainerMed_2 116066 BP_ContainerMed_2
LogTemp: Warning: InitialLevelLoad: Will be reloading this as BP_ContainerRecycledEnergy_2 116065 BP_ContainerRecycledEnergy_2
LogTemp: Warning: InitialLevelLoad: Will be reloading this as BP_ContainerWorkbox_2 116064 BP_ContainerWorkbox_2
LogTemp: Warning: InitialLevelLoad: Will be reloading this as TestElevator_2 116063 TestElevator_2

On Reload of same level:
LogTemp: Warning: ReloadingLevel: Reloading BoxToStartMissions 116072 BoxToStartMissions
LogTemp: Warning: ReloadingLevel: Reloading FMCIntel_Pickup_2 116070 FMCIntel_Pickup_2
LogTemp: Warning: ReloadingLevel: Reloading ImpactWrench_Pickup_2 116068 ImpactWrench_Pickup_2
LogTemp: Warning: ReloadingLevel: Reloading BP_ContainerBase_2 116067 BP_ContainerBase_2
LogTemp: Warning: ReloadingLevel: Reloading BP_ContainerMed_2 116066 BP_ContainerMed_2
LogTemp: Warning: ReloadingLevel: Reloading BP_ContainerRecycledEnergy_2 116065 BP_ContainerRecycledEnergy_2
LogTemp: Warning: ReloadingLevel: Reloading BP_ContainerWorkbox_2 116064 BP_ContainerWorkbox_2
LogTemp: Warning: ReloadingLevel: Reloading TestElevator_2 116063 TestElevator_2

I probably should delete this since no one responded, but just in case someone else has the same question… GetName() worked fine as a consistent unique ID in the packaged game as did the GetObjectName(). I did a packaging and displayed the values from these and they were functional and as consistent in the packaged game as they were in the editor and thus I was able to use them as a key in save files to reference back to the live object in the world/level. The GetUniqueID() still exhibited the same behavior in the packaged game of being unique to the specific level load, but not always unique between two different loads.

This seems to suggest that an answer provided in the answers application, where the individual said you could not trust GetName() in a packaged game, possibly either a problem with an earlier version of the engine, or was just wrong. Of course a third option is that it works on the Mac and not on Windows, but that is VERY highly unlikely since Unreal normally works worse on the Mac. I’ve not tested it on our Windows box.

4 Likes

Please keep it and thanks for updating. Great to know that both GetName() and GetObjectName() work in editor and packaged game. Cheers.

I’m actually finding that GetObjectName varies between loads, at least for spawned actors such as the player.

I’m looking for a solution, as it’s difficult figuring out which player gets what inventory from load to load, as well as other spawned actors that get individualized items that should remain consistent from a save to a load.