Forum rules - please read before posting.

Inventory System stops working after restarting Unity

edited September 2017 in Technical Q&A
Hi :-)

So I finally got my Inventory System to work. After clicking on an object, the item goes straight in the inventory. I also figured out how to use an Inventory object on an In-Game object, and for it to change Scene afterwards (in 'ActionList Editor', 'Switch Scenes')

I assume it's easiest to make a new Scene for each Room View and after unlocking doors? I tried to test if the inventory would work throughout several scenes, and I think it works, with keeping all objects that are already in the inventory. Can somebody confirm this?

But unfortunately, the inventory system stops working, after I restart Unity. Do you have any idea why that could be ?
There's like a bug or something (although I followed the Inventory instructions of the Tutorials step by step).

However, I do get Warning messages in the Unity Console while the game is running:

-'Note: The MainCamera is parented to an unkown object'
- 'No player found - please set one using the Settings Manager, tagging it as a player'
- 'Main cursor has no texture- please assign one in the Cursor Manager'
- 'There are 2 audio listeners in the scene. Please ensure that there is exactly one'

Could these have anything to do with my Inventory System breaking upon restart?

Please note that my point & click game is in 1st person (2D). That's why I did not assign a player. As for the main cursor having no texture, I removed it because I don't want a texture on my cursor either.

I would be very grateful if somebody could help me with those issues. I'm kinda stuck :-(

Comments

  • Inventory items are retained across scenes, yes.  But you keep referring to "Inventory System" with caps - are you talking about another asset, or are you just using AC's inventory features?

    You haven't described in what way the inventory stops working.  Does it fail to show?  Does the game crash?  Please illustrate with screenshots if appropriate, as without knowing more it's difficult to suggest a solution.

    However, check that your game's Managers are still properly assigned in the main Game Editor window.  If you didn't save the project before editing, it may be that they weren't properly loaded into the editor - see Section 1.3 of the Manual.

    The MainCamera error will show if you've parented it to something, which shouldn't be necessary.  Where is it placed in your Hierarchy, and what is the other object that has an Audio Listener component?

    If you have no Player, set the Movement method to None in your Settings Manager - that will stop that message.

    If you don't need a cursor, you can set the Display cursor setting to Never rather than not giving it a texture.
  • Hi,
    Thanks so much for your help. I made some progress, thanks to your advice.

    Okay, so I got rid of the Main Camera warning message, by moving the main camera in the hierarchy. 
    I thought that maybe the Audio Listener issue was the fact that there were several cameras in the hierarchy. (the one I already had in my game, plus the ones that got imported by AC)
    So I removed the extra ones and only have 'Main Camera' left, but a warning message is still showing up. 
    I solved 'Display cursor' and removed the player. So I managed to remove a few warning messages.

    These are the other remaining warning messages: 
    'PlayerPrefs Key' AC_Point&Click_0 loaded
    and 
    'Metal: Editor support disabled, skipping device initialization'

    Do you know what they mean ? Some screenshots are attached.

    When it comes to saving my progress, I usually just click 'cmd' + 's' within the scene. Do I need to save the project in another way¨?

    Ever since I cleaned up the warning messages though, inventory seems to be working again even after restarting Unity. (the object that I would previously click and went to the inventory, couldn't be clicked on anymore. Stopped reacting)
    I just did the test. So picking up objects works fine now.

    I'm on to the next step: using an inventory object on an in-game object and for it to change Scene (key opening door for ex.). I'm not sure if I set it up correctly, because it's a little buggy right now. 
    Basically I take Object A (key in inventory) and use it on Object B (door) and it doesn't change scene after combining the two. But it does change Scene after clicking on the door hotspot, without the key. A view from the Action List Editor of the Object B for this is in a screenshot. I used Inventory 'Remove' object and 'Scene' Switch. 

    Thanks so much :-) 



    image

    image

    image


    image

    image

    image

    image

    image

    image

    image

    image
  • I thought that maybe the Audio Listener issue was the fact that there were several cameras in the hierarchy.

    Try disabling various cameras in the Hierarchy while the game is actually running.  The AudioListener message will stop printing when you disable the offending object, which you can use to work out which one has the second component.

    Do you know what they mean ? Some screenshots are attached.

    The PlayerPrefs message is not an error, but just AC informing you about the save game data its storing and retrieving automatically.  It can be safely ignored.   The Metal message is Unity related, and you'll have to search Unity's documentation / forums for info on that.  Clicking any message in the Console window will reveal if it's an AC message or not.

    When it comes to saving my progress, I usually just click 'cmd' + 's' within the scene. Do I need to save the project in another way¨?

    That just saves the scene.  Managers and ActionLists are stored as asset files, which live outside the scene.  To save those, go to File -> Save Project from the top toolbar.

    Basically I take Object A (key in inventory) and use it on Object B (door) and it doesn't change scene after combining the two. But it does change Scene after clicking on the door hotspot, without the key. A view from the Action List Editor of the Object B for this is in a screenshot. I used Inventory 'Remove' object and 'Scene' Switch.

    Those are the correct Actions, but the screenshot doesn't show in which ActionList they're running.  Is that in the Hotspot's "Inventory" Interaction, or the "Use" Interaction?

    Bear in mind that you will need to have a way of recording the fact that the door has been unlocked, if you want the player to be able to return to this door later.  You can do this by creating a local boolean Variable named e.g. "Door is locked".  Set this to True by default, and then use the Variable: Set Action to change it to False when the key is used on it.  The door's "Use" Interaction can then contain a Variable: Check Action to check that variable's value and either let the player go through it, or return an "It's locked" response from the player.  Concepts like this are covered in the video tutorials.
  • Hi, 
    Thanks for your reply. It's really great to receive such good support on this forum. (especially for struggling newbies like myself.. ) 

    Sorry for not mentioning it, the actions are on the "Use" interaction of Object B (the door)
    But it's not an issue anymore. I fixed that bit in the meantime and should work fine now.

    I'm on to the two final steps to make my inventory system final.

    I need to be able to combine certain objects in the inventory (pieces of a picture for ex.) So if I go to the inventory, click on Object A, and drag it to object B, it becomes object C in the inventory. I've been looking for a tutorial that explains that, I haven't found one. Do you have any advice?

    The second and last thing I need to be able to do, is that 'zoom' on object, that I mentioned on an earlier post. It's not a fancy zoom, no animations, no rotating around the object. It's just basically clicking on an object in inventory, and then it goes to new scene (where I place the image in big) and goes back to previous scene after clicking on it again. It's basically a scene switch after clicking on an inventory item. Is this possible? 


  • edited September 2017
    I need to be able to combine certain objects in the inventory (pieces of a picture for ex.) So if I go to the inventory, click on Object A, and drag it to object B, it becomes object C in the inventory. I've been looking for a tutorial that explains that, I haven't found one. Do you have any advice?

    Core operations such as inventory combining are all covered by the Manual - see Section 6.2.  Combine Interactions are listed at the bottom of an items' properties in the Inventory Manager.

    The second and last thing I need to be able to do, is that 'zoom' on object, that I mentioned on an earlier post. It's not a fancy zoom, no animations, no rotating around the object. It's just basically clicking on an object in inventory, and then it goes to new scene (where I place the image in big) and goes back to previous scene after clicking on it again. It's basically a scene switch after clicking on an inventory item. Is this possible?

    You can place a Scene: Switch Action inside your Inventory item's Examine interaction to open a new scene when you right-click.  To load the previous scene, you'll have to invoke the SceneChange script's LoadPreviousScene function.

    You can do this by running the following line of code:

    AC.KickStarter.sceneChanger.LoadPreviousScene ();
    (For more about calling AC functions through script, see Section 12.2.)

    However, I'll be adding a new Scene: Switch previous Action in the next update, which will run this for you.

    If the zoomed-in item is just a sprite/texture, though, you may not necessarily need a separate scene.  A full-screen Menu could also serve the same function.
  • Hi,

    Thanks for your comments.
    I checked section 6.2 of the manual to see how to combine inventory items. So I have to set the Inventory interactions as 'Multiple' for this to work?
    I checked the Inventory Settings of the Setting Manager to set it to multiple. Did this menu change with a new update by any chance? It doesn't display the same thing on my Unity as on the manual (please see screenshot)
    I don't see where to set it to multiple. 
    If I manage to work this out, will inventory item A, be able to turn into inventory item C, if combined with item B?

    As for the Zoom on inventory object. Do you know when the next AC update is due?
    Ideally, I wanted to be able to zoom on an object with a left click instead of a right, for a scene switch. Do you know if this possible with this version or the next update?

    image
  • I checked section 6.2 of the manual to see how to combine inventory items. So I have to set the Inventory interactions as 'Multiple' for this to work?

    No.  There's a two-line break after the section on "Multiple" mode where the words apply to all modes.  I'll see about making that more clear.

    The ability to define Combine interactions is already displayed at the bottom of your Inventory Manager for each item.

    I checked the Inventory Settings of the Setting Manager to set it to multiple. Did this menu change with a new update by any chance? It doesn't display the same thing on my Unity as on the manual (please see screenshot)
    I don't see where to set it to multiple.

    It is unavailable if your Interaction method is set to Context Sensitive - see the note at the start of the section.  You don't need to change it, however, to make use of inventory combinations.

    If I manage to work this out, will inventory item A, be able to turn into inventory item C, if combined with item B?

    Yes, but that's down to the Actions you run within the interaction itself.  Three Inventory: Add or remove Actions would do it - two to remove item A and B, and another to add item C.

    As for the Zoom on inventory object. Do you know when the next AC update is due?

    I'm planning on this week, unless a showstopper bug delays it.

    Ideally, I wanted to be able to zoom on an object with a left click instead of a right, for a scene switch. Do you know if this possible with this version or the next update?

    "Use" interactions are left-click, so you can just map the ActionList that creates the zoom to the Use interaction instead of Examine.
  • Hi,

    Many thanks. I think I almost got it now. 

    So I did the following for combining inventory items:

    I went into the Settings Manager and checked the box 'Drag and drop inventory interface' and also checked the box 'Combine interactions work in reverse'.

    I have two items in my inventory now: 'shoes' and 'screwdriver'. I want those two to become a third item. 
    I went into 'Combine interactions' in 'Inventory Settings' and did one Action List Asset for 'shoes' and one for 'screwdriver' by clicking 'create'. (screenshots attached). So I created a combine event for both items. 
    Now I'm just missing the last step. Them two becoming a third item after being clicked and dragged on each other. Where do I set this up? Is it in 'Crafting' perhaps?

    Would it be possible to explain the last part step by step? 
    Thanks again for all your help so far.

    imageimage
    image


    image


    image
  • The Crafting tab is for a separate feature that allows you to combine many items together to create new ones - Minecraft-style.  For a simple "use one item on another", the Combine interactions section in the Items tab is all you need.

    When creating a new Combine interaction, you select an item that it is intended for.  You currently have two such interactions for each item.  The "shoes" item, for example, does not need a "shoes" interaction because that will run when combined with itself.  To combine it with the Screwdriver, you need only the first one defined.

    As you have also checked Combine interactions work in reverse?, you do not need to create a "screw" interaction in the screwdriver's own list of combines.  So of the four interaction's you've defined, only the first one on the Screw's page, which has Screwdriver beside it, is necessary.

    To have that interaction remove both the screw and the shoes, and create a new item, you just need the following Actions I described earlier:

    image
  • Ok thanks !! it works. Awesome. :))
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.