x

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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How do I make an Array be chosen randomly, but each actor at least once?

Hello, I have connected up a random integer in range to a Get Actor Array which is plugged into a Spawn actor. This spawn actor is triggered by a for loop to spawn 25 actors in a grid. The Actor Array has 4 different actors, so the grid has 4 different actors that are spawned in a combination that is different every time. I want to either make some actors less probable or some actors happen only once (but still spawn randomly). How do I do that? I've included a picture of the current setup. The for-loop that I was talking about comes from the Input's top execution.

alt text

Thank you,

TIG

Product Version: UE 4.12
Tags:
untitled.png (428.1 kB)
more ▼

asked Aug 20 '16 at 01:03 AM in Blueprint Scripting

avatar image

TalkingIsGreat
43 12 15 20

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

1 answer: sort voted first

To get control over spawn percentages, you could just set the index value of the Get node as a variable, determined by something like a d100 roll (if you're familiar with tabletop games) with ranges for certain spawn percentages (return 0 if roll < 30, return 1 if 30 < roll < 60, return 2 if 60 < roll < 85, return 3 if 85 < roll or something like that).

Here's a quick function I whipped up, but with the spawn chance variables disconnected so you could see the numbers in the < nodes.

alt text

And here's what it would look like in use. You don't have to pass the integer value through as an output since we could always just Get the variable instead. But this feels cleaner and makes me happier.

alt text

If you only want it to spawn once, then you can simply store nothing or a base enemy type in its place in the Actor Array after its spawn logic fires.

EDIT: This will need a lot of additional stuff if you're wanting to spawn potential groups of things on each run through the loop.

spawnrandomizer.png (276.9 kB)
spawnfollowup.png (63.1 kB)
more ▼

answered Aug 20 '16 at 04:31 AM

avatar image

rbmiracle
232 10 9 23

avatar image TalkingIsGreat Aug 20 '16 at 07:18 PM

Thanks for replying! The top picture controls the probability of the actors, but by some super rare chance only one of the actors could spawn, and there has to be certainty that at least one of each will spawn. What would I need is either one of the actors to spawn once or for the spawn to be random but at least once. How would I do the thing that you mentioned at the bottom?

(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