I have "Save asset references with Addressables" checked and I'm trying to spawn an NPC and have him persisted during scene changes.
After marking the NPC as an addressable, I can successfully spawn him using a "Object: Add or remove" action (entering the addressable name). But he isn't saved to the scene, so I added a RememberTransform (with "Save scene presence" checked and the name of the addressabe is entered). But this resulted in the following warning when running the "Object: Add or remove" action:
"Agent(Clone) cannot be instantiated, as it is already present in the scene. To allow for multiple instances to be spawned, assign a non-zero value in its Remember Transform component's 'Linked prefab ConstantID' field."
I don't really understand what the warning means, and I don't see any 'Linked prefab ConstantID' field on the RememberTransform.
AC: 1.76.3
Unity: 2021.3.19
Thanks!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Three things I noticed when digging deeper into this:
Thanks for the details. To be clear: the original warning appeared regardless of whether or not the NPC was actually present?
That sounds like a conflict between RememberTransform and RememberNPC, which both deal with the attached GameObject's Transform data.
I'll look into this, but an alternative approach to this would be to enable Player-switching, convert the NPC to a Player, and use the Player: Teleport inactive Action to spawn them. When dealing with such Players, AC handles their scene presence and position automatically.
Yes, it happens no matter what.
Yes, I was surprised to see that RememberTransform was needed in order to have objects remembered in saves, perhaps a separate RememberScenePresence would make more sense.
BTW: I tried removing the RememberNPC component, but I have the same problems remain.
Thanks for the workaround, but I already use player switching and I'd rather not mix up players and npcs.
Thanks for looking into this, if you find it can be made to work with a few code modifications (or an updated package), please get back to me 👍