Is there a unique ID for actors placed in the level that is stable across executions and modifications to the level?

Is there a globally unique ID for actors that is reliable and stable enough to be put in a save file? In other words, if something in the save file had an ID, would it be able to reliably match that to the exact same actor when loading the game? Bonus points if there’s a built in system in the engine to get the actor pointer from the ID.

In the level blueprint you can save an actor reference as a variable, you should be able to pass it to the save game but it’s a pointer, not an ID

Hmm, interesting. That implies that there is a unique ID then otherwise the engine wouldn’t be able to resolve the pointer when loading the save file.

I’ll see if I can learn more about that. Thanks.

1 Like

Ue5 uses a new system called “one file per actor” (can be also enabled in UE5 through experimental settings), every actor placed in a level has a file in a folder in the root (the name starts with two underscores but now I don’t remember it), if there’s an ID you can probably find it there

uassets are binary data, so there’s not really a way to easily pull out variable names.

In UE5.1 an actor placed in a level does have a GUID. You should think the other way around though since you need to be able to restore actors spawned by code as well. In theory you should only need to save “what class, at what position, with which properties” and spawn a new actor with that data when loading a save.

3 Likes

This wouldn’t be for respawning the actor. Ares9323’s initial response does cover where my actual question came from which is how to save references. If two actors are paired to each other in some way, you need a reliable way to repair them when loading a save. Obviously saving raw pointers wouldn’t work but if Unreal is setup to serialize out pointer properties, that covers like 90% of cases where a unique ID would be needed.

1 Like

Have you tried using GetObjectName? That function should return an unique ID of an object placed in the world (as you can read here, it’s unique only in a specific level, so that’s probably why it’s only available in the level blueprint)

Edit: there should also be a GetUniqueID function (but this post is 9 years old and I haven’t tried it)