I am building a RPG. Currently I have a working inventory which stays alive during the entire game in my Canvas. And I activate/deactivate it when needed. As well as read/write from file on start/end.
This works fine for my Inventory since its never destroyed. However, with chests I am a bit confused about what the best approach is, should I:
Keep every Instance of chest inventory alive and activate/deactivate it? Then write/read to file on start/end? This seems a bit ugly if player has like 20+ chests.
Instantiate/Destroy chest inventory every time I click the chest. This would also mean that every time I open a chest, I have to read its contents from file, and every time I close it, I would have to save its contents to file. Would this be bad for performance or is taht the way to go?
What do you mean, “stays alive”? I’m guessing you mean it’s instantiated once and doesn’t destroyonload.
As with chest storage, just do the same thing as you did with the inventory system. Why would a player have 20+ chest storage? Shouldn’t you just have an inventory system and a storage/bank system? Perhaps I’m not understanding your problem correctly.
If I were you I would do the same thing with the inventory system except with more slots. Then make the gameObject active when you talk to a certain person or something.
You can place your own chests, like in Minecraft. Not sure if youve played it but sometimes you end up with 20+ chests because you run out of storage. I.e a chest has limited amount of slots, for example 20 slots. For example each chest “inventory” is 15 slots, so if I have 20 chests, Ill have 20 Instances of the chest inventory.
If there was just one instance then ofc Id treat it the same as my Inventory
Thanks!
I haven’t really played Minecraft and I’m going to keep it that way
In this case, make your HUD DDOL (this is what I have) and then instantiate a new chest into that. Then you can activate/deactivate it every time by clicking on an icon for example. When you say “place your own chest” do you mean dropping a chest and able to pick up again later? Did you also want to do that?
Okay. Unless you’re making an MMORPG, I still don’t think you’ll have to instantiate and destroy it constantly. Again, I would instantiate another inventory type object into the players HUD, and instantiate the actual chest. (Are you right-clicking the chest icon in your inventory to “drop” it?). Then you’ll have all your objects with you all the time, but it’ll only be accessible when you interact with the corresponding chest. Does that make sense?
Of course, you’ll have to destroy the chest if you want to pick it up, but then create a chest icon in your actual inventory that is still linked to the corresponding chest.
Thanks for your advice. As for my inventory and placement systems they are all in place and work as intended. So this was all I was wondering about I think Ill try this approach first then since it’s definently the easier one. I have a thing about not wanting too many DDOL objects in my game but I guess this will be OK!