Download

Finding an actor in a map between play sessions.

I am trying to write a some persistent object code. On BeginPlay in my PersistantObjectManager I am loading some data from a SaveGame. I want to apply this data to the AActor it was saved from. I am having trouble finding the same actor between map loads. I was unable to use AActor.GetUniqueID() because it is different between map loads, I also looked at FUniqueObjectID which had the same issue. What is the best way to find the same actor? It is assumed the AActor is in the World when the world loads and wasn’t spawned after.

Best,
Jason

If the actor was loaded directly from the map, use object path name. Or generate GUID on SaveGame.



/** IsNameStableForNetworking means an object can be referred to its path name (relative to outer) over the network */
bool AActor::IsNameStableForNetworking() const
{
    return IsNetStartupActor() || HasAnyFlags( RF_ClassDefaultObject | RF_ArchetypeObject );
}

bool AActor::IsNetStartupActor() const
{
    return bNetStartup;
}




/** If true, this actor was loaded directly from the map, and for networking purposes can be addressed by its full path name */
UPROPERTY()
uint8 bNetStartup:1;


Well the game isn’t networked so I don’t need to worry about that. I guess you are saying use AActor::GetFName() and use that as the identifier? If so how do I get object by name?

GetAllActors and then find Actor that matches? I am looking for the most efficient way in code to get an object that is in the world map.