Forum rules - please read before posting.

Creating a game in chapters--and questions about persistent variables?

Hi again everyone! I've been using Adventure Creator for a bit on a smaller project and I really enjoy using it. However, I've got a bigger project I've been meaning to get started on and before I get too-too deep into things, I want to make sure I can make it work the way I want to in Adventure Creator!

I apologize in advanced if this post is lengthy or disorganized, I just want to try getting all the details down so there's no confusion.

Essentially I've got a big game project I'd like to create using Adventure Creator. I would like to release the game in chaptered releases, not only because the game will be a long undertaking but also because I feel that narratively the game's story works better being split up into "episodes". I've seen other games made in Adventure Creator have chapters/episodes (Sally Face, for example) so I know it's possible to some degree. However I am struggling a bit when it comes to figuring out how I'll go about it, specifically when it comes to things like Saving/Loading + Remember Components.

I started a new Unity project and threw a bunch of test assets in there to try and figure out how this could work. I was able to get a pretty basic Chapter Select screen working in a custom menu. I click on "Prologue" and it takes me to one scene, and then I click on "Chapter 1" and it takes me to the other. Perfect! But then I get stuck on how this would work gameplay-wise.

Originally I was going to have a "Back to Title Screen" button in my in-game menu, and have the game bring the player back to the Chapter Select screen after beating a chapter. But if I do that, then things that changed in the chapters/scenes won't come back if I try to play them again. For example, the prologue scene just contains a hotspot that tells you you beat the prologue when you click on it, and then moves off-screen. But when I open up the title screen again(without closing the game and from within the menu), and then click on the prologue again, the hotspot is still moved off-screen because of its Remember Component. I'm not sure how to make it so that the chapter and all its scenes can "reset" itself again when you click on them from the Chapter Select screen, but still keep their "Remember" properties when loaded in again from the Loading menu.

I could technically just do away with bringing the player back to the titlescreen and just forcing them to quit after each chapter is finished(though this isn't ideal), but that still leaves another problem--I'm not sure how to make the game remember which chapters have been beaten already when opening the game again and being taken right to the Chapter Select screen.

I've made a few games in the visual novel engine Ren'Py this way. I made games that updated in chapters, and then using Ren'Py's persistent data feature, I was able to make it so that the game remembered which chapters had already been beaten using persistent variables. This way, players could not skip ahead in the story without beating the previous chapters first, but the game would still remember which chapters they beat even if they never saved the game.

I'd like to accomplish this in Adventure Creator, too. Let's say I update my AC project to have Chapter 1 after releasing the Prologue. I want returning players to be able to play Chapter 1 right away, but I'd like to prevent new players from just jumping right into Chapter 1 without playing the Prologue first. Is there any way to have some sort of persistent variable that remembers which chapters have already been beaten and isn't attached to a player's save file(since I don't want players to save/load into the Chapter Select screen)?

I've got the feeling that this might require some sort of custom script or code to accomplish, but I know next to nothing about coding so that's really intimidating to me! Still though, any help or advice is appreciated, as I'd really like to use Adventure Creator if possible for this project. I hope this wasn't too confusing of a read! Thank you in advanced!

Comments

  • Hello, my first post here so apologies if I don't quite get it right

    From what I can see you have multiple possibilities:

    Use PlayerPrefs to store Variable, such as int currentlyOnChapter = 0 (Meaning you are in prologue). Your custom menu would check that variable and enable/disable Chapters according to that (if it's 0, player has to start from prologue, if it's 1 from chapter 1 etc.). This way is simple, but I'm guessing also not very "safe".

    But personally, I would consider converting your Title screen to AC scene and store this data in similar way, only as Global Variable(either int or couple bools) And set this variable via that "Last hotspot" on scene/chapter.

    Regarding the "reseting" the scene, couldn't this be done by using the Scene Switch actionlist with parameter Reload even if already open?

  • @StanleyRos Forgive me if I misinterpret anything you say or get confused, I'm still pretty new at this but thank you for reaching out!

    I see what you mean with storing variables in PlayerPrefs, I'm pretty sure! I had to link it to Options Data, correct? I see how it stays consistent now even without saving! It's most likely what I'll go with unless someone is able to offer an alternative.

    I'm not very sure what you mean by this though:

    But personally, I would consider converting your Title screen to AC scene and store this data in similar way, only as Global Variable(either int or couple bools) And set this variable via that "Last hotspot" on scene/chapter.

    My titlescreen is already an AC scene I'm pretty sure? Unless it means something different than what's in the tutorial... And would it not still need to be linked to Options Data? I don't really follow, sorry :') (It also might be worth noting that my Title and Chapter Select screen are controlled by menus and buttons, not hotspots. I don't know if that affects anything.)

    Also, I'm unsure about this as well:

    Regarding the "reseting" the scene, couldn't this be done by using the Scene Switch actionlist with parameter Reload even if already open?

    I just tried doing that and it doesn't seem to change anything, it still seems to be following its Remember Transform component. Also maybe I should have mentioned it earlier, but each chapter will be composed of multiple scenes. So even if I'm able to reload the scene one starts in I'd still have to find a way to reset all the other scenes in the chapter too, right?

  • edited July 2023

    For persistent data, Global Variables linked to Options Data are the way to go - no need for scripting.

    They'll be stored as part of a Player's Profile, separate from their save-game data. By default, this'll mean its stored in PlayerPrefs.

    When it comes to resetting data, the Engine: End game Action's Restart Game method can be used to restart all game data as though you were closing and re-opening the build.

    Doing so requires a scene-change, however - so you could have your "Return to Title" button/feature run this Action and have it open up your Title screen scene with this Action, rather than the regular Scene: Switch.

  • @ChrisIceBox I just tested that out now--wow, that works like a dream! I learn something new about this every day. This is a huge worry off my back, thank you so much for the help!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.