Forum rules - please read before posting.

Scene change forgets picked up items

edited September 2018 in Technical Q&A
Hiya, using Unity 2018.2.2f1 and AC 1.64.1.  Big fan of AC and would love input on my latest roadblock :)

My problem is two part: I have the player pick up a couple food items, combine them to make nachos.  1. When the player leaves the scene and re-enters, the items are all back in the kitchen. 2. When I try to turn off the item's hotspot, either via code or via Remember (using state on start: off), the hotspot remains on.

Few things are weird about this situation (and info about my setup):
- It used to work, which makes me wonder if an update changed things?
- I tried using the api for disabling and enabling hotspots (e.g. even for picking up an item) and that doesn't seem to work. Sample code: obj.GetComponent<Hotspot>().TurnOn();  so as a temp solution I use SetActive() (only works for enabling/disabling the object on pickup, does nothing for the re-appearing on scene load)
- I have a lot of checks around each item, for example if local variable nachosMade is true, don't show these items. The local var nachosMade saves and is consistent on scene re-load, but the items still load.  An example of that code:
       switch (obj.name){
            case "Cheese Block":
                if (AC.KickStarter.runtimeInventory.IsCarryingItem(3) || AC.LocalVariables.GetBooleanValue(2)) {
                    break;
                }
                obj.GetComponent<Hotspot>().TurnOn();
                obj.GetComponent<SpriteRenderer>().enabled = true;
                break;
- I have remember hotspot and remember visibility and constant ID on each item.  The default is set to "on" for these, so maybe this is where I'm going wrong? Does this default overwrite things that happen OnStart?

Any input would be greatly appreciated! I feel like I've been going circles on this one and it's gotta be something more simple than I'm making it into...

Thank you again :)

Comments

  • Indeed - this shouldn't be a complex problem.  Simply having the RememberHotspot component attached should ensure its state is saved - regardless of its "State on start" value.

    So that we can ensure no conflict, remove all custom code that's turning the Hotspot on/off - for the moment, just rely on using the Hotspot: Enable or disable Action to affect its state.
    1. What platform are you targeting / building to?  Does this occur in both the Editor and builds?
    2. Is it just the RememberHotspot component that isn't working correctly, or are other Remember components also having a similar issue?
    3. When was it working before?  An earlier version of AC, or an earlier version of Unity?
    4. Is the Constant ID value the same on both your RememberHotspot and RememberVisibility components for a given object?
    5. How are you leaving/re-entering the scene?  With the provided Scene: Switch Action?
    6. Do things restore proplerly if you save/load within the same scene?  i.e. save, pick up the items, and load back.
  • Ok, I created a new object, it has remember hotspot and visibility (with 'retain in prefab' checked) and a use action that disables the two.  I leave the scene and come back, visibility is still disabled but hotspot is enabled.

    1. Mac platform, I honestly haven't tried building it but I will next so I've only seen it in the editor.
    2. Just remember hotspot, remember visibility works as expected.
    3. I updated Unity and AC at the same time :| Was on Unity 5.6.6 before (I forget the version of AC but I kept that better updated)
    4. Leaving/re-entering with code:
        IEnumerator ToBos(){
            AC.KickStarter.stateHandler.StartCutscene ();
            KickStarter.dialog.StartDialog(KickStarter.player, "I'll just walk to Bo's, they live nearby.", false);
            while (KickStarter.dialog.CharacterIsSpeaking (KickStarter.player)){yield return new WaitForFixedUpdate ();}
            AC.KickStarter.stateHandler.EndCutscene ();
            AC.KickStarter.sceneChanger.PrepareSceneForExit ();
            UnityEngine.SceneManagement.SceneManager.LoadScene("BosHouse");
        }
    6. Uhh I also haven't tried save/load functionality, I'll do that next with the build.

    Thank you for the suggestions! I'll update in the next day or so with how the build and save/load goes.
  • Do both Remember components share the same Constant ID value?  There is currently a bug in which having multiple such components on a prefab causes them to be different, but this will be addressed in the next update.
  • Ah! Mostly solved!  I did end up having another script impacting hotspots (for changing rooms within a scene).  I still have one that seems to default to on even if it's been turned off (after re-entering the scene) but I think I can debug it from here. Thank you so much!!
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.