Forum rules - please read before posting.

How to stop inventory images to reappear in scenes?

edited January 2018 in Technical Q&A
Hi,
Quick question.

Okay so I have a built in Inventory thanks to AC. The picked up objects remain in my inventory across scenes and everything works fine, except when I return to that scene where I picked up the object, the object is there again.

Is there a way to have them be deleted from the scene once and for all after being picked up?

Comments

  • edited January 2018
    You must attach the appropriate "Remember" component to any object whose data you want saving.  For example, to save the visibility of a sprite that becomes invisible when the item is picked up, attach the "Remember Visibility" component.

    See the "Saving and loading" chapter of the Manual for a full runthrough of how the save system works.  Each of the video tutorials also provide practical examples.
  • So you mean I need to attach the 'Remember Visibilty' Script on the hotspot of the object picked up? I tried that but it did not work.. :(

  • That was an example.  Each Remember component saves a specific type of data - again, please see the Manual.

    The Remember Visibility component will save the visibility of an object (e.g. a sprite or model).  You'd attach this to the visual representation of the object you pick up.

    The Remember Hotspot component will save the 'enabled' state of a Hotspot, which can be turned off with the Hotspot: Enable or disable Action.  If that's how you're disabling the Hotspot, that's the Remember component to attach.
  • edited January 2018
    Hi,

    Thanks for your response
    I read the whole "Saving and loading" chapter of the Manual and watched again tutorials, including the whole inventory section of this video, among others

    I understand the basic logic, I just really don't know how to execute it exactly and why it does not work on my game. I have tried many different things.

    To answer your message:
    What do you mean exactly with visual representation? The object or the hotspot?
    I tried attaching the 'Remember Visibility' Script on both and it does not work (..I read in another AC forum discussion that I'm supposed to attach this script to the hotspot, but did not work on my game). I also tried parenting the inventory object to the hotspot of the item, but that did not work either. I also tried checking and unchecking 'affect children''... 

    Also, I have tried attaching the 'Remember Hotspot' Script to the object's hotspot in the inspector. & then in the ActionList Editors, selected the Hotspot, and select 'disabled'. (where the inventory actions of the object are). Some screenshots below. 

    I don't understand.. If the system remembers to have this object in the inventory stored over several scenes, why can't it remember to deactivate this hotspot over several scenes once the object is picked up through the action list editor? What am I missing here?

    But even if I get the hotspot to stay disabled over several scenes, it still wouldn't solve the problem of the image of the object appearing each time the player reenters the scene (unless maybe object & hotspot were linked? That's why I tried parenting these two). So do I need to use 'Remember Visibility' as well as 'Remember Hotspots'? Or do I need to use Variables for this?

    I understand how to make the object invisible after picking it up while in the same scene, I just still don't quite understand how to set it up that it remembers across scenes. That's where I'm stuck.

    I would really appreciate some help, it's the last thing I really need to figure out before I can finish my AC game 
    Here are some screenshots:
    image

    image

    image

    image
  • edited January 2018
    By "visual representation", I meant the sprite or model (in this case, sprite) that represents the Hotspot.  With the example you've provided, that would be "screwdriver".

    The Actions look fine, but the last one (the 2nd Hotspot: Enable or disable Action) is superfluous and not necessary.

    The Remember Hotspot component goes on the Hotspot ("screwdriver_hotspot"), and the Remember Visibility goes on the sprite ("screwdriver").  I don't know where you saw mention that Remember Visibility goes on the Hotspot, but that would only apply if the Sprite Renderer and Hotspot components were on the same object.  No variables are necessary for this.

    If you have parented your sprite to the Hotspot, another approach would be to simply move the Hotspot out of view - avoiding the need to disable it and make the sprite invisible.  The Hotspot can be moved via the Object: Teleport Action, and saving would then just require a single Remember Transform component on the Hotspot.

    However, also know that AC is able to do attach the appropriate save components automatically - see the top of the "Saving scene objects" chapter of the Manual.  Upon clicking Auto-add save components to GameObjects, AC will search your scenes and attempt to add all the necessary Remember components for you.  But as this process updates your scene files, it's important to understand the logic behind this - and to backup your project first.
  • Hi,
    Thank you so much for your help. 
    Alright, so I removed the 2nd Hotspot: Enable or disable Action in the ActionList Editor. I attached the Remember Hotspot Script to the Hotspot and the Remember Visibility Script to the sprite. 
    Simply attaching the scripts does not work for me, maybe I am missing something else? The sprite is not parented to the hotspot at the moment. I made some research about this but can't get it to work.

    The scripts are only attached in this scene, where the object is picked up and added to the inventory, not to the others. 

    Some screenshots below.

    I have not tried the Auto-add save components to GameObjects. I could test it, but I do not mind doing this manually for now. I just have to figure out how.


    image

    image

    image
  • if you have a lot of objects  and hotspots, you can always try to create a variable that will check which objects are visible and which are not in certain scenes. Also, you can make cutscenes: OnLoad and OnStart where you can put a list of actions with the visibility of objects and hotspots .. In that way, you can further ensure that objects will not be visible when you move from one scene to another ... oh, by the way autosaving in AC, I can say, doing a very good job...
  • edited January 2018



    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}

    Hi,

    thanks for the tips.

    So I've tried Auto-add save components to GameObjects that Chris mentioned in his previous post (this is what you meant with 'autosaving in AC' right?) and it does not work for me.. I do get an error message in Unity though: 

    'ArgumentException: Scene file not found'. And the scene mentioned in this error message is always the current scene I am on (Screenshots below)

    The Scenes are added to the Build Settings though, so I'm not sure what the problem is.

    But this action does place the 'Remember Hotspot' Script to the Hotspot, and the 'Remember Visibility' Script to the object, so I did that correctly before. 


    As for the Variable approach, Chris mentioned in his last comment that creating a variable is not necessary for this, so then I thought attaching the Remember Scripts would suffice


    But I tried it anyway since I really want my game to work.

    I did the following:

    I tried adding a Variable in 'Variables', 'Create new Local Variable', Type: Boolean. Then I presume I need to hook this up accordingly in the ActionList Editor of that inventory object.. that's where I'm not sure what to add. Right now the ActionList Editor have the actions of disabling the Hotspot (but that only works if player stays in the scene) and the screwdriver object becoming invisible (also only works while staying in the scene) and the third action is adding this item to the inventory. How do I add an action that states that if Variable is True, the Hotspot/Object always stays invisible throughout the scenes? (screenshots below)


    I hope one of these will work, another solution would be to use the Remember Transform  by adding a Teleport box in the ActionList Editor, like Chris mentioned. I have not been using any markers for this game so I'm not sure how to set a marker to teleport to though. I tried with the ClickMarker Prefab, but it did not work


    Thanks again for your help and thanks for your patience, me being a total newb in game dev


    image

    image


    image


    image

  • 'ArgumentException: Scene file not found'. And the scene mentioned in this error message is always the current scene I am on

    The Scenes are added to the Build Settings though, so I'm not sure what the problem is.

    This may be the issue - does any such error appear when running the game / entering the scene?  Try typing 'bedroom_A' into the Project window's search bar - does anything other than the scene file appear?  It may be that the filename needs to be unique.

    As the 3D Demo uses many such Remember components to handle its saving, try testing that in your project.  You can load up the Managers + scene file via the top toolbar - just be sure to also add the "Basement" scene to your build settings.  An easy way to test saving is to go to the back of the room, save, pick up the sword, and load back.


    But this action does place the 'Remember Hotspot' Script to the Hotspot, and the 'Remember Visibility' Script to the object, so I did that correctly before.

    Indeed - the components you attached are correct.  There's something else causing this issue here.  What are your AC/Unity version numbers, and on what platform are you running?  Are all of the scenes listed in your build settings enabled?


    How do I add an action that states that if Variable is True, the Hotspot/Object always stays invisible throughout the scenes?

    Once we get to the bottom of the underlying issue here, this won't be necessary.  However for posterity, the way to do this is to create a new Cutscene that consists of a Variable: Check Action that reads the boolean variable.  Depending on its value, it either enables and shows the Hotspot and sprite, or disables and hides them.  Then, have your OnLoad and OnStart Cutscenes trigger this new Cutscene, so that its run regardless of how the scene is loaded.


    I have not been using any markers for this game so I'm not sure how to set a marker to teleport to though. I tried with the ClickMarker Prefab, but it did not work

    It requires a scene-based Marker, not a prefab.  Markers can be added via the 'Navigation' section of the Scene Manager's 'Prefabs' panel.
  • edited January 2018
    Hi :)
    thanks for your comment. So I checked, there are no other filename called 'bedroom_A'. Currently all existing Scenes are added to the Build Settings. 

    An easy way to test saving is to go to the back of the room, save, pick up the sword, and load back.

    I'm not exactly sure what you mean by that. How do I test saving? (My player can't save in my game. I don't want to include the Save & Load option. I'm making one of those online games where the player has to restart the game of he quits the page)

    What else does the 'Auto-add Save Components to GameObjects' do exactly other than attaching the Remember Scripts for you? Is there anything else I should be checking for?

    Here are my version numbers:
    Unity Version: 2017.1.1f1
    AC Version: 1.59

    All of my scenes seem enabled (screenshot attached). Although it seems as though one is not, but that's just because the checkboxes are not properly aligned it seems. But there are currently 11 Scenes and will add more later.

    I did not further go into the variable for now, since it's not necessary for this to work. Do you have any idea what could be the issue? 

    image
    image
    image
  • You have a lot of missing scenes in your build settings - this is normally caused by adding scenes to it, and then deleting the scene files.  That your checkboxes are also misaligned makes it look like this is a wider issue with Unity.

    Try selecting each of those disabled checkboxes with no scene name next to them and deleting them by pressing backspace - so that only those 11 listed have checkboxes.

    The "Auto-add" button only adds Remember / Constant ID components.  The components you already have are correct.

    By "test saving", I meant for you to simply play the 3D Demo scene using its own Managers - regardless of how your own game handles saving and loading.  This issue looks to be more to do with your Unity project, rather than your scenes.  If the 3D Demo doesn't work as it should, then it would suggest that's indeed the case.
  • Okay, I deleted the missing scene files. Tested it again and same result.

    I tried the 3D Demo. It also does not work with the demo, object reappears in scene after coming back. And loading this 3D Demo changed some of my game settings in my Scene (buttons don't appear where they should anymore etc.)

    Hmmm.. I really don't know why it does not work. Any other suggestions? 
  • edited January 2018
    I also tried the Transform approach you mentioned:






    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}

    It requires a scene-based Marker, not a prefab.  Markers can be added via the 'Navigation' section of the Scene Manager's 'Prefabs' panel.







    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}



    If you have parented your sprite to the Hotspot, another approach would be to simply move the Hotspot out of view - avoiding the need to disable it and make the sprite invisible.  The Hotspot can be moved via the Object: Teleport Action, and saving would then just require a single Remember Transform component on the Hotspot.


    So I put the hotspot as the child of the sprite. 'Remember Transform' Script is attached to the Hotspot in the Inspector. I added a box in the ActionList Editor: 'Object' 'Teleport, Object to move: 'Screwdriver', Teleport to: 'Marker' and I dragged in 'Marker' as well as 'Marker2D' from 'Prefabs' 'Navigation'. I placed both markers outside the scene and tried with both.


    This approach doesn't work for me. I did watch the online tutorial about this bit. What am I missing here? 

    If I could get this to work I could use this in my game instead of 'Auto-add Save Components to GameObjects'. Please see screenshots below.


    image



    image


    image


    image

  • edited January 2018
    The 3D Demo uses a 3D camera perspective, while yours relies on it being 2D.  You must be sure to switch back to your game's own Managers before loading up your own scenes again.  This can be done automatically by double-clicking your ManagerPackage asset file that the New Game Wizard created when you used it.

    When you loaded a save in the 3D Demo, was the player's position being correctly restored?

    That the 3D Demo also doesn't work suggests there is a larger issue with your project - and saving won't work regardless of which components / method you use.  Whether you use "Remember Transform" / "Remember Visibility" / the auto-add feature is irrelevant - as saving itself is not occuring at all.

    You still haven't said which platform you're running on.  It might be that I just have to open up this project for myself.  Would you be able to zip it up and PM it to me?
  • Hi, 
    Thanks for your response.
    I don't have a player's position, my game is set to first person. 

    I'm running this Unity project on a mac. I would definitely be able to zip it to you and PM it to you. Thank you so much for this, it's really awesome. Where would you like me to send it to?
  • I was referring to the player's position in the 3D Demo - I need to know if no data is loading properly, or just "Remember" compoents.

    You can host the file on e.g. Dropbox and PM me the link.
  • Ok thank you. I sent you the zipped file via PM.

    The Scene I'm working on is bedroom_A_3, which contains a pick-up item that goes in the inventory
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.