Save actor data when destroyed and spawn this specific actor
Currently I have an inventory and weapons that can be used. For equipping weapon functionality I use "Spawn Actor from Class" node. It spawn a actor from my Parent Weapon class. If I unequip/move that item into my inventory the actor gets destroyed. So when equipping the same weapon it spawn a fresh actor from that class: For example equipping BP_AssaultRifle then unequipping and equipping it again it will spawn BP_AssaultRifle_1 then BP_AssaultRifle_2 and etc..
My problem is that I want to be able to save the current item status when unequipping it and spawn it with the same status when equipping it again but I'm not sure which unreal functionality I should use for that purpose.
So I've been able to do something similar but without destroying the spawned actors. Also I'm thinking of other work around like keeping the ammo count in the character.
Edit: Thoughts on the workaround - Current ammo should be stored somewhere as we don't want the owner to set it to 30 every time he unequips and equips the weapon. So the work around will work only for the Max ammo..
Edit 2: My Inventory items are based on Structure that includes ID, Name, Type and etc. One of these structure variables is my ParentWeapon where I can select the Weapon Class. I have components that remove and add items to a array of elements from my structures type.
Please share your ideas and advises with me :)
Thank you very much in advance!!
You could just have a function in the player for each type of inventory item class that has the same variables you need to store (weapons, power ups, etc) and call that function which then saves a class specific struct of variables. Then when you spawn the next actor use the struct variables to set the new actor parameters.
answered Mar 29 '18 at 04:25 AM
Nebula Games Inc
Follow this question
Once you sign in you will be able to subscribe for any updates here