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"

Spawning Multiple items to Target Points

Hello,

Right now, I have a working spawner that can spawn one item in random places. This is exactly what I need, but I have six key items I need spawned instead of one. Does anyone know how to set this up for multiple items? Would C++ be a better way to do this? (If so, please give me a starting point, I have already mixed C++ and blueprint in my project.) Or is it just okay to copy and paste this 6 different times?

Here is the Blueprint: alt text

Product Version: UE 4.13
Tags:
blueprint.jpg (147.5 kB)
more ▼

asked Oct 29 '16 at 09:15 PM in Blueprint Scripting

avatar image

SilverMantis
1 2 3

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

1 answer: sort voted first

You could use a for loop to repeat that operation any number of times you need

alt text

more ▼

answered Oct 29 '16 at 09:19 PM

avatar image

Rekenq
722 19 6 26

avatar image SilverMantis Oct 29 '16 at 09:36 PM

This works partially, the only problem is that when items spawn, they can spawn into/on top of each other. Is there a way to make sure they all go to separate spawn points?

avatar image Rekenq Oct 29 '16 at 09:40 PM

Yes that is perfectly possible. How many spawn points do you have?

avatar image SilverMantis Oct 29 '16 at 09:42 PM

Right now I have 6. The example I showed above was me just testing with 2.

avatar image Rekenq Oct 29 '16 at 09:46 PM

Ok what you need to do is something like this. You should create an array that has the references to your 6 spawn targets. Then on each loop cycle after you spawn your object you take the index that you used and remove that from the array. So each time the array gets shorter, just remember than you should take into account that since the array is getting shorter your random integer max should be reduced by one every time.

avatar image SilverMantis Oct 29 '16 at 09:56 PM

I totally understand what you are saying in concept, but in Blueprint, what would I use to take the index of the array to remove it? I'm fairly new, and have only been studying C++ for a month and Blueprint in even less time.

avatar image SilverMantis Oct 29 '16 at 10:03 PM

So when I used a Integer - Integer function, they all spawn in the correct places with no stacking. So now the only problem is getting them to spawn randomly between the 6 spots. ( I plan on having 12 spots, so that the keys will always be in a different place, without stacking) haha This is what I used. I was using random integer in range to make them spawn in random spots, but in order to get them to not stack, I used Integer - Integer, which no longer has them spawn randomly just in order of the spawns.

alt text

blueprint2.png (112.3 kB)
avatar image Rekenq Oct 29 '16 at 10:29 PM

which no longer has them spawn randomly just in order of the spawns

Well that's because you are using the index from the for loop and not the index from the random integer node. Did you try it the way I did in my image?

Edit: Besides I just noticed that you aren't even using an array variable, did you even check the image I posted?

avatar image SilverMantis Oct 29 '16 at 10:41 PM

Yes, I re-did everything in your image (: I had seen it a bit too late, so that comment came before.

avatar image Rekenq Oct 29 '16 at 09:54 PM

Something like this

alt text

array.png (147.7 kB)
avatar image SilverMantis Oct 29 '16 at 10:33 PM

This is method you've created works, but they are still spawning on top of each other. The items I have for testing are these boxes. As you can see they are spawning and then just stacking. alt text

stackboxes.jpg (101.5 kB)
avatar image Rekenq Oct 31 '16 at 03:10 AM

Oh sorry there was a mistake in the code that I posted. I assumed that RandomInteger would return the same value for both of the pins if it was accessed within the same line of execution but it seems like it isn't that way. What you need to do is to create an integer variable and then set it with the value from the random integer node then connect that variable to the Get node and the remove index node and that should do it

avatar image SilverMantis Nov 02 '16 at 08:36 PM

Thank you for trying, but it still didn't work out. When I added the integer, it just make them spawn in a row again, as in 1 - 6 slots every time. ( I have 8 slots currently so in theory they should randomize between them). Maybe I should just find another way to go about this, I don't want to wear you out. haha.

(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