Spawn a random Item without repeating

Put the berry numbers in an array and then shuffle the array ( there’s a shuffle node ). Then just use a loop to pick the berry numbers out of the array. Each one only happens once :slight_smile:

Hi everyone!
So I made a Blueprint Actor called “Spawn Berries” with three arrows, where in the Event Begin Play, spawns three random objects in each Arrow [screenshot01].

The problem is, that sometimes it repeats the same Object and I just want to be each arrow with a different object. Can someone help me?

(Note: I created four Functions: One to get the Arrows Location [screenshot02], the other three to spawn the object [screenshot03]).

You need to make a parameter on your berry BP so you can choose the color

( you can do it and keep your separate berry spawn events, but then instead of colors you need an array of class types ). Tell me how you get on…

Ok, then you need to do the array of class types thing…

Then you do it like this:

The type of the array is now ActorClassReference.

Oh, I’m going to try it!! Thanks !!
(Ah, I don’t need to change the colors, because they aren’t the same object/actor. The berries are actually Blueprints Actors too)

Okay I have a question!
The part of the Array which is a ActorClassReference, in my case the Red Berry is an actor, the Blue Berry is an Actor too and the Yellow one the same. So when I make the variable map, I just can choose one… So, how did you make it?

If I’m not mistaken, you have your class array variable type set up as Red Berry. That actually needs to be a class reference to Actor or Pawn or whatever your berry actors are. So if they’re just regular actors in this case, you need to change your array of “Class”. Change it’s “Variable Type” to “Actor” and then choose class. That should solve your problem I think.

Sorry for the delay, email problems. Just make 3 pins on the make array, and set one to each kind of berry class.

( you need to have all you berry types in the make array list )

Ooh okay, thanks!! It worked!!

It’s okay, don’t worry! It’s working now, so thank you so much! You helped me so much!

Okay, sorry if I’m annoying but I found a problem:
So, when I move my Spawn Actor of the Berries and press Play, the Berries are in the middle of the map floating. I check out my Blueprint Code and it’s the same as yours… What could it be wrong?

Yeah, you left out the connection to the transform array:

288191-array.jpg

I connected them, it’s still having the same problem*

GetWorldTransform on the arrows :slight_smile:

Oh God, it was that! Thanks! :smiley: