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"

How to pre-generate and "save" characters/items.

Hey all. My characters and items are completely random gen. With lots of different stats, descriptions, visuals and effects, my characters are getting quite complex as well.

Understandably generating everything on the fly makes the game have it's hiccups. All the code that random gens the npc and items, building etc... is random and done in the constriction script.

My question; is there a way to generate a library of npc, items, etc... On begin play, then save them and when the game needs to generate a new item instead pulls from the list of saved ones. Then when the list gets low enough repopulates it?

Any help appreciated, thanc.

Product Version: UE 4.21
more ▼

asked May 02 '19 at 04:07 PM in Blueprint Scripting

avatar image

46 1 3 7

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

1 answer: sort voted first

Sure, just spawn them early, keep them in an array or a map, hidden. You will pay for this with a higher memory footprint, of course. You cane use Game Mode / Game Instance for this since they are easily accessible from anywhere.

What you've described is very similar to pooling. If you want to have 100000 bullets flying around, spawning them (very costly) will cause performance issues. Instead, they are spawned before combat and kept in a pool - if you need one, you take it from the array (it's just a pointer so the cost is minimal) and handle it the way bullets handle. Rather than destroying them, you put them back in the pool. Pretty much every games does this.

I simplified it a bit but that's the gist.

edit: alternatively, pre-generate data, save structs to a Game Object. Spawn blank object without running the costly generator in the Construction Script and grant it data loaded from the slot. This may be a better solution if it's the random generator that is slowing everything down.

more ▼

answered May 02 '19 at 04:24 PM

avatar image

15.3k 77 26 64

(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