I’m following Ryan Laley’s Inventory System Tutorial, and this is something I haven’t seen him cover, which is the fact that if I create a second type of object to collect in the inventory, the object being destroyed doesn’t save when I open the game again.
So my question is, how do I get the second object to save after it’s destroyed and not reload in when I start the game up again? (the second object is the key and the first is the seashell. The seashell saves it’s destruction just fine.)
Because I don’t want my players to be able to drop items, I skipped the part of the tutorial that lets you drop them (you may destroy them in your inventory instead) because of that I had to find a different way to do what he’s doing here
This is what I have instead for the code, it doesn’t work, I tried to adapt it to what I’m doing but its not working.
To my knowledge the key and seashell have the same parent and all and it calls the parent function on event begin play so… not sure why it isn’t working.
its hard to follow that without knowing the full context so a few thoughts
never use GetActorOfClass, you dont know what actor that will be
if you’re removing from inventory whats the map you’re adding too? if its a map of objects that have been picked up? if so then it should be on pickup not remove?
Yeah, I figured using GetActorOfClass wasn’t the right move, I’m just really am not sure what to use. When they are destroyed, the item is destroyed (demonstrated here)
And here’s the code for remove inventory (although I don’t think it’s related to the problem, I could be incorrect. I fully followed the tutorial for this part though)
The logic is in an actor component I’ve created based on the tutorial, the bulk of the logic for the entire system are made up of different functions inside the component.
This is the logic that’s meant to save the removal of the key from the world.
It works on my seashell items, but not the key item.
And this is the logic that happens when the game is started up again and is told not to spawn the objects that have been picked up.
i’ve not used this system but you’re using soft object references? my understanding is there is no guarantee the objects would have the same object reference the next time you load, meaning the value wont pass the IsValid check?
if so i’m surprised Ryan used this method, but i could be wrong
Here are all of the places that I use my actors added.
Actually, for the game mode begin play, when I remove everything after the complete loop (so actors added ‘keys’ and onward) The issue seems to be resolved, but in the future, I may want to utilize the add actors array, and I don’t know if this is a sustainable solution.
For this one, it’s odd because I don’t want the actors added to the scene so I’ve skipped past that step, but I’m not sure if I am doing that wrong. Not sure if related though at all. This is the only area place I would have added anything to the Add Actors array though.
you can search you’re entire project to see if there is an ActorsAdded somewhere else, this is also a good lesson on why you should encapsulate that logic in functions.
but also if you ever Add an actor you must remember to remove it on pickup/destroy
So the blueprints above are ALL the places I put the ActorsAdded array, so I’m unsure what I’d be searching for. I am having trouble understanding what is the course of action at this point in fixing this issue, I’m sorry
Oh, I see- my apologies for not understanding at first.
So right now I do not have a use for actors added, though I will need it if further in the game an item spawns for the player to pick up. When I remove all parts of the code for actors added, specifically in the Event Begin Play on my game mode, it seems to work accordingly. I don’t know how to fix it so in the future I’d be able to add actors without unwanted actors spawning, though.
I’ve also removed the actorsAdded from InventoryRemove but it doesn’t seem to have any effect.