Download

Weapon Pickup spawn random location done differently

This BP spawns my weapons bit it will randomly spawn two or three of the same weapon.
I am trying to get all of the weapons to spawn at the same time.
However, I need them to switch their positions around when they do spawn.
What am I missing, please?


do spawn.
What am I missing, please?

The instances somehow need to know who is spawning what so they don’t spawn the same one.

I am sorry, but your reply is extremely general.
Can you please be more specific? :slight_smile:

The spawners do work but they spawn more than one of the same kind of weapon off and on and I need it to spawn one of each of the weapons that I have variables for consistently.

Random Int in Range will give you a number in that range, but it can and will repeat. That is why you are getting two or more to spawn the same.

There are several ways you can always avoid a repeated number. One is: populate an array with the integers in order and shuffle, then spawn in order of the array.

Like so:

RandomSpawner

That seems to have done the trick.
Thanks. :slight_smile:
I did have to do the BP differently though.
Now I just need to figure out how to use it to spawn more than one actor.

Yours looks better though.

I am just trying to avoid using a level BP.
Stand alone BPs are best.

That is already set up in the link above:


SpawnLocation is an array that hold placeholder actors just to get their location. So if you have 3, it will get all 3 and update the int array accordingly.


Since the int array is same size as the places where you want to spawn your clases, it will loop and execute once per location.

image
Here notice I added % node → What this does is that no matter how many places I have to spawn weapons, it will never go out of bounds. Just make shure that when you add / remove classes from the select, update the number accordingly.


Finally this spawns and adds a reference to an array just in case you want to do anything else.

All you have to do is populate the SpawnLocation array:
RandomSpawner2

Updated the link with all the nodes:

1 Like

I will give it a try.
Thanks.
I will not be destroying the actor though.

Did it to demo. You are free to modify as you wish.

I tried it and yours does not spawn BPs.
It only spawns items.
I tried to plug my weapons into it and the nodes an incompatible.
But I truly do appreciate the help.

It spawns what ever you want as long as you set up the logic right. :eyes:

I will work with it and again, thanks.

I am thinking that you have a different version of UE.
I just copy and paste your code into my own PB and I get nodes with errors.
I fix them and after that when I test the spawner it always spawns multiples of the same weapon and nothing I do fixes it.
There has got to be something different between your setup and mine.

It will not work if you simply copy / paste.

I suggest you use what I shared as reference and build based on your needs.

BTW, if you need help understanding something specific or with a particular problem, feel free to ask and I’m sure either I or many others that lurk in these forums are more than willing to help.

1 Like

Can you get your BP to replicate and run from the server so that all players in multiplayer will see weapons and use them?
I have been fighting with different ways to do it ever since we last communicated.