Glad Sam brought up objects that are spawned at runtime

I think I understand that objects that are spawned at runtime need to have an ID assigned to them, when Instantiated by the spawner; onto the SaveableEnity, of that Prefab using a unique ID like a large 50 char randomly generated string.

(because Prefabs are what will be Instantiated the prefab should have a SaveableEnity.cs on them right? only missing the ID)

Is this a true statement?

Thanks

Actually, if the objects are spawned at runtime, it’s better to have all of the Capture and RestoreState in the object spawner… the Spawner should maintain a list of the objects that it has instantiated, and when CaptureState is called,it should save all of the information needed to respawn that item in RestoreState. If the item already has a SaveableEntity component attached, this will confuse the saving system, if for some reason (like it was picked up) it’s no longer in the scene…

In short:
If it’s placed in the scene heirarchy by the developer, i.e. it’s in the Scene file, it should have a SaveableEntity with an ID. If it’s spawned into the game after runtime, then the responsible object should have a SaveableEntity with an ID, and should return a list containing the information needed to respawn and correctly restore each entity it has spawned.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms