Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

alt text

alt text

Product Version: UE 4.20
more ▼

asked Nov 03 '18 at 04:25 PM in Using UE4

avatar image

16 1 4 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Nov 09 '18 at 12:35 AM

avatar image

111 2 3 4

avatar image mattyi85 Nov 09 '18 at 01:02 PM

brilliant thanks for the sensible response worked like a charm as soon as i took the do once out of the function and into the event graph it stopped firing it hundreds of times. I wasn't aware that they couldn't be used inside functions thanks so much :-)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question