Hi,
I’m working on a system where I use TargetPoint
actors to randomly spawn a blueprint item every 2 seconds. I already have a working setup that randomly chooses a TargetPoint
and spawns the item there.
However, the problem is: sometimes the item spawns on top of an already existing one, which looks very bad. I want to prevent this from happening — once a point is used, I want to avoid spawning another item there again.
Someone gave me this idea as a hint:
First, create two arrays of
TargetPoint
actors (let’s call them Array A and Array B).
AtBeginPlay
, add all of your TargetPoints into Array A.Every time you spawn an item, pick a random index from 0 to the last index of Array A, and use that to get a TargetPoint.
After using that TargetPoint, remove it from Array A and add it to Array B.
When Array A becomes empty, refill it using the items from Array B.
(If you only want to use each point once, then you don’t even need Array B.)
This hint sounds useful, but I’m still a beginner and I’m not sure how to set this up in Blueprints.
Can someone kindly show me how to do this step by step, or maybe even share a simple example?
Thanks so much in advance!