I have an array which spawns an actor with a random rotation every 1.5 seconds.
The problem is that it spawns the actors on already occupied target points.
I need to tell the array not to spawn at allready taken target points.
Any idea how i could do that?
So far I have not found the solution am looking for.
Thanks for any help
Hi, before starting the spawning, save the array into a variable. Then use that variable in the “GET”. When you spawn the “Banana Retop” remove the item from the array variable to avoid using that transform again. Further use “LENGTH” of the array variable -1 as “Max” in “Random Integer in Range”.
There are two different nodes to remove an item from an array. One called “Remove” takes in the item and removes all instances from that item from the array. The other is “Remove Index” and takes an integer and removes the item at that index.
Therefore you would plug the output from the “GET” into the “Remove”. Further you would need to set the Max value of “Random Integer in Range”
And further I would rather use a timer to drive the spawn. So something like this
Thank you so much! It works now.
I need to study the logix behind the remove index some more. Don’t quit get it at the moment but I haven o more overlapping at the target points!
Have a nice weekend and again thank you very much!
Oh no now once the array has used every position it won’t start over.
On every target point spawns a destroyable object. once it’s destroit on the target point it won’t spawn again on said point.
Is there a node to refresh the array?
So I gould add a branch with true = all index removed get array variable?
You could replace the “Event Begin Play” with a “Custom Event” and call that “Custom Event” after the “Event Begin Play”. So if the array is empty you can call that “Custom Event” again, and it will start from the beginning.
And there’s a node called “Get All Actors Of Class” that you could use instead of making the array, so you don’t have to reference them by hand.
Hi thank you for the fast answer!
How can I remove the item from the array? The removenode turns blue and i cant connect the random integer.
Still don’t get the logic.
Wow **“Get All Actors Of Class” is greate! thanks for that tip.
Ok it works now for my purpose. It would still spawn objects at an already occupied targetpoint when no actor at all is destroyed. But its like a shooting game so at least some targets should be empty after the first cycle.
Thank you so much for the fast help!
All the best from switzerland.