I would give all your inventory items an integer to ID them, and then add durability to an array of integers or floats. Youd then be able to use the ID to find the item in the durability array to give to the object when its dropped from the player or spawned in. To keep that item in the world then, youd need to pass that durability value to the world object so it retains its durability
I was wondering how I could store an instance of an actor. For example: I have an actor I want to store away in a variable and then delete itself so I could spawn it later from the array, but I want it to retain the variables from the earlier instance that was deleted.
Ex: I have a sword with 4/10 durability.I want to store it away in my inventory in an actor variable and delete it, so I can drop it later and spawn it with the same durability
Depends how you are identifying a sword as “4/10” durability. For example…is this sword upgraded by the player and all swords obtained by the player are at this level? Do you have many swords in your levels and they each have random “durability”? I could better assist you if I knew how the swords are created with their “durability” to start and how much variation do you have between swords?
You could create a defined struct, make an array of those somewhere, and just copy the sword stats into it when you store/delete it. Then when you create it back again, just retrieve the data and pass it on to the new actor.
its the same when you wanna load a unit into a transport in a game. the unit is actually gone, just the relevant data is stored and then passed into a new actor when you “unload” the unit.
Game is all smokes and mirrors man
To give some context: I have a working inventory system which holds an array of actors. I can set the actors I pick up to the actor variable, but I don’t know what to do past that. I could just store a class instead, but then any modified variables attached to that instance of actor is lost.
I’d like to store actors with modified variables so I could replicate them later.