So I have certain cutscene-type events that will spawn a prefab in the scene. Often times I have that prefab stick around through several events in the chain.

Now I notice that if I save the game in between one of these events, the prefabs are not saved along with the game, which totally makes sense.

How would you go about doing that, in a sort of generic manner? Since this is likely something that will come up hundreds of times im not sure where I should hook in to reduce the chances that i forget/break it in the future.
  • Is the spawned prefab always the same one or would you need to handle different prefabs?
    If you're enjoying my products, updates and support, please consider supporting me on!
  • It changes depending on the chain of events in question.

    Maybe its another party member taking part int he chain, maybe an enemy, npc, or other major character. Its not an issue when the event is self contained, but I have some that span multiple discrete events that I'd like to be able to save state in between.
  • Hm ... generally, saving the state of a running event is currently not possible.

    You could probably use some save solution that enables you to save spawned prefabs, maybe in combination with ORK's custom save data or component save data, or maybe use game variables to store information on the spawned prefabs and their position and use a global event that's called after loading the game to spawn them again ...
    However, that doesn't solve the core issue of retaining the event's state and connecting the prefabs to the event's prefabs again ...
    If you're enjoying my products, updates and support, please consider supporting me on!
  • oh the event isnt in progress.

    I chain together multiple events with gameplay in the middle. The best example is like a running tutorial where you have some npc spawns at the beginning and follows you through the tutorial.

    There are discrete events that happen along the way, but its not one giant protracted event.
  • edited May 14
    If you add the NPC as a member of the player group (i.e. a combatant) and spawn the group in the field, the NPC would be saved and respawned by save games.

    And you can easily access the NPC in the events via the Member actor.
    Post edited by gamingislove on
    If you're enjoying my products, updates and support, please consider supporting me on!
  • Ok that works for certain cases.

    Now, imagine the case where i have a cut scene where i have spawned some prefabs for a boss, for example. Theres some back and forth, then i fight them (in a different scene) and load the stored scene back again.

    How can I spawn those objects such that they would persist through the scene change for battle? Are scene objects saved with a running scene? And if so, can I spawn a scene object dynamically?
  • You'd use game variables for remembering at which state you currently are and have the scene set up to react to it. There are 2 ways to do this, either having the game objects already in the scene or spawning them by an autostart event (which can also continue your cut scene).

    Having game objects already set up in your scene uses Variable Event components to destroy them if their variable conditions are not valid. You'd basically have everything already in your scene and destroy the objects that are not needed based on variables.

    Or using an Autostart event interaction with variable conditions to start after the battle, spawning the needed prefabs and continuing the cut scene.
    If you're enjoying my products, updates and support, please consider supporting me on!
  • Forgot to mention that I got all of this working with a custom node. To survive a game reload I had to use a library to recreate objects, however in game recreation across scenes is all handled without any new dependencies.
Sign In or Register to comment.