So, I'm making an inventory system for an rpg style game and I've gotten it to where you can go into a store, buy an item and the press I to access your inventory. However, when I leave the store all the items are gone, but if I come back they're back. It seems like some sort of issue with the different layouts even though I gave all the items the persist behavior and made the inventory layer global. Any help on how to fix it would be very appreciated.
What store? You sent us a full game with no info on what to do.
Oh shoot, sorry, I sent the wrong thing. You can go to the store from the Village Layout and get items from the first building. I'll try to find the version that's just the store.
Here's the short version, sorry again. Just go into the store and press E to buy an item. Also, to use the potions drag and drop them onto the knight. The issue is that you can see the item in your inventory inside the store just not when you leave.
Are variables being reset when you switch layout?
When you enter the store the items are put on the Inventory layer which is layer 10. When you return to the level the items move down to the Buildings layer which is layer 10. If you are using global layers they need to match throughout the game in terms of number/index so they should match between all layouts. Think of it like the items are positioned on a numbered layer rather than by name.
You could create a work around such as 'on start of layout' set invitems layer to "Inventory" but that is kinda forcing the position and soon it'll get overwhelming as you add more things that you need to force the layer position etc and bugs may occur, I believe the best practice is to match layers across all layouts then you can take advantage of their global-ness.
Develop games in your browser. Powerful, performant & highly capable.
I see, thank you so much for the help!