Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hi! Sorry I couldn't reply before. Gateway's developer here.

Would you mind giving me some more information about the issue?

  • Is the Unity editor just crashing or does it log something to the console?
  • What do you have besides the narrative part? Remember that the loading can only restore the state of the Story, but it cannot automatically handle whatever happens outside the scope of the Narrative Director, this should have its own save/load system in parallel to the one provided by the Gateway.
  • What happens if you try to do save and load on a minimal supersimplified version of your prototype? Let's say it's just got the same basic structure but a supersimple .ink file, like just a few lines.

Feel free to share more, I really hope we can fix this together. Just forgive me in advance if I cannot reply quick enough, I know it can be frustrating.

(4 edits)

No worries at all!! I really appreciate the help!

The Unity editor just crashes. It happens immediately after the load command is reached. Nothing is logged to the console.

I do have a few variables that are saved in Fungus parallel to the ink saves, but it’s limited. I’m using checkpoint saves, and at the beginning of each knot, I send a message to Fungus flowcharts that should set the background/sprites/etc. I’ve used the gateway’s saving in a previous game (with Unity 2022.3) and loading all the visuals via Fungus saves and that worked fine.

In testing I’ve done since my initial message, I’ve realized that the issue may be caused by a change I made to the Narrate function in the Narrative Director. (I did not have these changes in my last project.)

I changed the first if condition in the Narrate function to a while loop that gathers all the lines so that they’re printed together.

string allText = "";
SayDialog sayDialogTemp = sayDialog;

while (story.canContinue || loading)
{
    foreach (Flag flag in flags.Values)
    {
        flag.Reset();
    }
    if (!loading)
    {
        story.Continue();
        if (beforeFirstSync)
        {
            SyncAllVariablesToFungus();
            beforeFirstSync = false;
        }
    }
    string line = story.currentText;
    if (line != "" && line != "\n")
    {
        allText += line.TrimStart();
        allText += "\n";
    }
    Log(LogLevel.Narrative, "»" + line);
    ProcessTags(story.currentTags);
}

I then send allText to the sayDialogToUse. (I’m not using characters, only narration.)

Would you have any ideas about why this might be messing up the loading or whether there’s just no way to get the loading to work with Narrate set up this way?

No rush in replying! Thank you so much for your help!!

Hi zorkie,

 this code change is definitely sus. :-D 

I'm looking into it, my memory fails me and I need to check the code more thoroughly. Back to you as soon as possible.

In the meantime, have you tested what happens if you revert the code change? Does the load/save work?

(1 edit)

OK, the code change is the culprit in my opinion.

When you load a save point, Narrate is called with loading = true. The loading flag is set to false only after Narrate returns, in the final line of Load. This means that your while loop goes on forever, which crashes Unity.

I guess you could fix it by adding something like this:

while (story.canContinue || loading) 
{
  // ...
  if (loading)
  {
     // Stop the loop after one iteration
     loading = false;
  } else { 
     story.Continue();
     // ...
  } 
  // ...
}

I'm not sure about this, though, because I don't know the details of your code.

I believe I see what you're trying to do here: I guess you want a long multi-line text to be displayed at once, and the breaks are only when a choice is to be made. I would have done it differently, which does not mean it's better, just safer. I would have created an intermediate object that collects and concatenates all the messages instead of the SayDialog, and called sayDialogToUse.doSay only when a choice is to be displayed.

Let me know if your modified Gateway finally works as expected!

You were right, setting loading to false worked! Thank you so so so much!!!

In my code, I collect/concatenate all the text in a string (allText) and then call sayDialogToUse.doSay when the story reaches a choice (it’s outside of the loop). So far, I’ve been operating under an “if it works, it’s good enough” mentality haha – but I’m very open to suggestions for improvement if you’d advise any!

Thank you again for your help!! I really appreciate your support!

Great! Glad to be useful sometimes.

I understand better your code now, it's basically the same solution I was suggesting. :-D

If more people were using this tool, I would probably consider to add it as an alternate mode. For some kind of games, it makes a lot of sense!