# How to make a collectible spawner?

**URL:** <https://forums.unrealengine.com/t/how-to-make-a-collectible-spawner/844458>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [April 4, 2023, 4:10pm UTC](https://forums.unrealengine.com/t/how-to-make-a-collectible-spawner/844458 "2023-04-04T16:10:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![szereny\_tonhal](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@szereny\_tonhal](https://forums.unrealengine.com/u/szereny_tonhal)\
**Post date:** [April 4, 2023, 4:10pm UTC](https://forums.unrealengine.com/t/how-to-make-a-collectible-spawner/844458/1 "2023-04-04T16:10:50Z")

</div>

I’m trying to make a collectible spawner that spreads actors to “random” locations. I can’t figure out how to make one. I have targetpoints placed on the map where I want to spawn collectibles. I want it to look random but not too random.

A simple (random int in range, branch and destroy actor) isn’t working well enough, because sometimes it spawn too few, sometimes too much.

If i could give it a minimum and maximum value to spawn between but still keep it random, not to spawn 2 at the same location, and also spread it across the targetpoints randomly so that it doesn’t only spawn on one side of the map.

---

<div class="post-metadata">

**Author:** ![GRIM\_Warlock](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/grim_warlock/32/642970_2.png) [@GRIM\_Warlock](https://forums.unrealengine.com/u/GRIM_Warlock)\
**Post date:** [April 4, 2023, 8:02pm UTC](https://forums.unrealengine.com/t/how-to-make-a-collectible-spawner/844458/2 "2023-04-04T20:02:16Z")

</div>

Hi

The simplest way to do that is to store all your target points in an array and create a variable INT with “Random Integer In Range” to specify your min and max spawns.

Shuffle the target points array and a normal For Loop to your random int as your index for target point in the array.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/5/3/f53a84425b621a4f57dc90ef664fabf0625c98eb.png)

Just make sure your Max spawn isn’t larger than _Target Points_’ Last Index

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [April 5, 2023, 3:56am UTC](https://forums.unrealengine.com/t/how-to-make-a-collectible-spawner/844458/3 "2023-04-05T03:56:58Z")

</div>

my personal approach is to create an actor class that spawns items at the placed location. I’d set it up so that what that spawner can spawn is defined in the placed actor. I would also use an item table (data table → TMap) to define the availability of each item type.

Have a collision component that on overlap of a player it spawns the random items from its list (item table availability validated) and then destroys itself.

_NOTE…_ triggering the collision and spawning only happens on the server.

Then simply place and configure the actors around the map.
