Forum rules - please read before posting.

Link global variable to option data / Continue dialogue after scene switches

Hi everyone!

Right now I'm sitting in front of the final big technical challenge before demo release. Since it's a main feature I would like to know if it's possible/reasonable to implement my idea the way I imagine.

The players will unlock trophies over the course of the game. Those should be visible in a sort of trophy room, which should also be accessible from the main menu (from all save slots together). The trophies would be arranged in a menu and become clickable once they're unlocked. Clicking it will switch the scene and the trophy is shown with a short animation. The trophy scene includes a big hotspot that leads back to the previous scene.

The idea was to use global variables to save which scenes were unlocked in which savegame, and to link an additional global variable to option data, so in the main menu the progress of all savegames can be seen too without loading a specific save.
I wanted to use a separate scene per trophy because I wanted to animate it slightly, but I'm open for better ideas. Having a separate scene already hits following problem: A dialogue starts and during the dialogue the trophy is unlocked. The scene switches to the animation scene, and afterwards I want to return to the previous scene to continue the dialogue. But so far the dialogue simply continues during the trophy animation, and only once the dialogue is finished the hotspot to return to the previous scene becomes clickable.

I'm thankfull for ideas and approaches on this topic :)

Comments

  • I can only speak generally without seeing the specifics of your setup / desired behaviour, but a separate scene shouldn't strictly be necessary. You could spawn in the animation as a prefab, and/or use Timeline to handle the animation.

  • Hey,

    Sorry if this was worded a bit chaotically, I'll try to describe again what I aim to achieve.

    I created several 2D animations and want to play them at three occasions:

    1. Discovering them during the game
      The player completes a quest (through dialogue, handing in an item, crafting something etc.). This is rewarded by an animation, which should be looped until the player clicks to continue the game, and a global variable it set to true.

    2. As a review within the game
      Ingame there should be the option to view all unlocked animated moments again. For that purpose I have a scene with a crystal ball which when clicked opens a grid with previews of the animations as images. Animations that are not yet unlocked should be blurred. If you click on an unlocked animation image the animation should play again, and the player returns back to the grid menu when they click.

    3. As a review within the main menu
      In the main menu there should be the option to view the progress of all unlocked animations too. Here I wouldn't read the global variable, but instead the option data/playerprefs, so the player sees really all unlocked animations they ever saw in all savegames, even if one save was deleted or overwritten.

    I had a look at the Timeline feature for the first time today. It seems to be a good start. Though for my project it would mean having two scenes (main menu and crystal ball scene) with many timelines/animations, instead of having many separate scenes with one animation each.

    What other information about my setup would be helpful? I'll glady submit it later.
    Adventure Creator: 1.85.3 | Unity 2022.3.62f3

  • I'm not seeing a reason to involve multiple scenes from your description. You can attach a Timeline to a prefab, spawn it in (with Object: Add or remove), and then play that Timeline back using the Engine: Control Timeline Action - all within the same scene.

    Having the Player "click to continue" may be possible with ending your ActionList sequence with an Input: Check Action on a loop. Otherwise, an Active Input that you activate at the end of your sequence that then removes the spawned prefab.

  • Hey,

    thank you for the help, I was able to implement most things. 1.+2. of the previous post is completely functional as I thought.

    1. is almost ready too. There are two remaining questions for now:

    For the gallery I created a menu using the Unity Ui In Scene, which I start via Crossfade from the Main Menu.
    When opening the gallery I would like to execute an ActionList when turn on: which should exchange a blurred picture with its original, and enable the according button.

    The first smaller problem: The UnityUi seems to be loading slower than my ActionList when turn on: The actionlist tries to exchange pictures in a menu that doesn't exist yet. So far I can avoid that by including an Engine: Wait with 0.1s at the start of the Actionlist. That's generally ok, but for those 0.1s the old picture is still visible and it flickers. Is there a way to conceal this flickering or is there a completely different solution for it?

    The second problem concerns the disabling of buttons. When the picture is blurred, its corresponding button should be disabled. Nevertheless it needs to remain visible, so a Menu: Change State: Hide Menu Element wouldn't work.

    public void Unlock()
    {
            targetImage.sprite = unlockedSprite;
            targetButton.interactable = true;
    }
    

    I used the first part of this Unlock function to exchange the pictures. I thought if I set Interactable of the button in the inspector to false by default, I can set it to true within the same function. But both buttons remain clickable, as if something else would overwrite the condition.
    How can I make a button non-clickable but still visible?

  • Is there a way to conceal this flickering or is there a completely different solution for it?

    To be clear: this is ActionList is assigned as that same Menu's "When turn on" asset?

    A wait time of -1 will cause a wait of exactly one frame.

    it needs to remain visible, so a Menu: Change State: Hide Menu Element wouldn't work.

    "Hiding" a menu element doesn't necessarily need to make it invisible - the behaviour is determined by the Button's "When invisible" field.

    If this is set to Disable Interactability, then it will just affect its Interactable field. In the Button's Inspector, you can alter its "Disabled" colour / sprite values to alter its appearance.

  • Yes, the Engine: wait is part of the same ActionList for When turn on:
    The -1 stopped the flickering effect, everything looks smooth now.

    Really unlucky, I tested for a solution with both seperately, but never tried them together. With this I got the desired behavior now, Thank you!

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.