Help with changing a spawned actor
I am creating a third person open world game. I have my inventory system all up and running and works great. Its called BP_Inventory. Currently I have to spawn it on "begin play" Screenshot below. In that screenshot on the spawn actor node you will see i can control the "Amount of slots" my inventory will have. Currently set to 20 if i press play and open my inventory i will have 20 slots. If i end play change the number to 50 then hit play again then this time i will have 50 slots.
The problem i have is that i want to change this at runtime so my player can start with 20 slots then when they get a level up they will have say 50 slots. Because this actor is spawned on begin play it obviously cant be done through a simple variable change.
I did try to create a function that destroys the actor then spawns it again with the new slot amounts, ive ran this through a "do once" node this function is in screenshot below. This works to a point it deletes the old inventory actor and creates the new one with 50 slots but even with the do once node it doesn't stop respawning them in the world outliner i watch it got from bp_inventory to bp_inventory1, bp_inventory2 and so on befor i know it im up into the hundreds and because it constantly spawns it again i cant actually pick up items as they are instantly deleted on the respwan. it also sucks up my system resources from constantly removing and replacing the actor.
Is there something i am doing wrong? is there another way to do this? tried so many different ways with varied results but cant seem to get it working i've tried to place the actor directly into the world rather than spawn it on begin play but then the inventory doesn't work at all. any help or ideas greatly appreciated if more info is needed please ask away ill reply as soon as i can.
asked Nov 03 '18 at 04:25 PM in Using UE4
It looks to me like the problem is with the location of your DoOnce node. A function is encapsulated so it runs and then removes itself after completion, so your DoOnce is essentially ignored.
I think if you move the DoOnce outside of the function, and place it just before the call to the function, you'll get better results.
Follow this question
Once you sign in you will be able to subscribe for any updates here