Hello,
I know this has been asked several times here, but I didn’t find a satisfying answer.
What I am trying to do is a system that will save some additional data for actors, which will be accessible even when actors are currently not in game (due to WorldPartitioning or beeing unloaded by DataLayer). For that, I wanted to use SoftObjectPaths as unique identifiers for actors (from my understanding, there is no other way to uniquely identify actors).
I need to be able:
1. Look up information for an existing actor
2. Look up actor using this ID (if it currently exists)
I don’t need to be able to force load the actor.
I need this system to work also for Actors that are in WP Streaming cells, and/or in Level Instances; and it needs to work for PIE, Standalone PIE and cooked game.
I originally considired both SoftObjectPointer and LazyObjectPointers, as both would be good enough for above requirements, but neither of them works. My current implementation is TMap<Soft/LazyObjPtr,StructWithData>. StructWithData contains further Soft/Lazy pointers (to the same set of actors that is in this map).
I have tried LazyObjectPtrs for a while, but they sometimes cannot be assigned in editor, seemingly randomly (I have’t been able to find a pattern), therefore I abandoned this solution. Also I don’t know how that would work with PIE+WorldPartition, as that would result in two actors having the same GUID? I dunno, I never got that far.
With SoftObjectPointers, I haven’t been able to make LevelInstances+PIE work. After duplication SoftObjectPointer contains a path that doesn’t point at any actor.
I have tried EditorPaths.Enabled, however that also doesn’t fully work (apart from beeing experimental and unsupported further). The SoftObjectPaths now resolve, but they are different from what Actor->GetPath() returns, which effectively means each actor has multiple different SoftObjectPaths. This breaks my requirement #1 - I cannot lookup information for an actor, when it is stored under a different SoftObjectPath.
I can theoretically at some point re-key my map, IF I had a way to convert all SoftObjetPaths to the “canonical” path (the path that Actor->GetPath() would return), without actually calling Actor->GetPath(), as this would need to be done at a moment when the Actor might not exists. Does such a
Summary of my questions:
1. Why can’t I sometimes assign LazyObjectPtr<AActor>?
2. Is EditorPaths.Enabled supported to the degree that further versions of UE won’t break it?
3. Is there a function that would convert EditorPath to correct SoftObjectPath, even when the actor doesn’t exists at the moment?
4. Is my entire approach wrong? I just need a unique identifier for an actor that persists across save/cook/duplication. Isn’t there a simpler way to do this?