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
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.
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.
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.
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
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.
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?
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.
It requires a scene-based Marker, not a prefab. Markers can be added via the 'Navigation' section of the Scene Manager's 'Prefabs' panel.
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.
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.
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?
You can host the file on e.g. Dropbox and PM me the link.