Tags and Arrays

Hello everyone, I could use some help with this, because it is driving me crazy!

Lets say we have 3 instances of the same Bp inside a level. The first one i tag [0] Spider1, the second one [1] Spider2, and the third one [2] Spider3.
I can easily save those tags into an array.

Now lets say i decide to destroy them and after a while i spawn 3 new instances of the same BP.

How the heck can i give to those new instances the same tags by using the (see image) array that contains the correct data?
In short how can i transfer the data from one array to another one (in this case the Tags Array)?

Thank you in advance!

You’d either need to spawn the 3 new instances before the old 3 are destroyed, and set the arrays, or store the arrays elsewhere until the new ones are spawned,. Perhaps someone more knowledgeable has another trick up their sleeves.

Don’t destroy the spider tags array and when you spawn the new 1 do a For Each Loop on your spider tags and then apply that tag to each 1 as it’s spawned.

I have already saved the data before i destroy them as you can see from the picture. The thing is that if i use a for loop when i spawn them and try to ĝet that data from the stored array and set that data to the tags array it only transfers one value.
Does anyone know or can give me an example on how to move one arrays contents to another?(in our case the tags array that is build in in every actor)
Thank you guys for trying to help!

From your picture you are adding the entire source array as a single element in the target, hence one element.

If the picture isn’t accurate, make sure you’re iterating over the source and not the target array.

I lost you there. :slight_smile:

Let me try and break it down in hope that i will understand what you just said.

I have a Tags array that derives from the blueprint actor (every actor has a tags Array build in). Every time i add a tag into an instance the Tags Array becomes bigger and bigger.
All that i can save in another Array for future reference in case i want to destroy all the instances.


The thing i do not understand how to do it is to take this information and add it to the newly spawned instances of the blueprint. Whatever i do i have only managed to transfer only one value over to the Tags Array.

Note: This is just a placeholder. I haven’t actually hooked anything up.

I kind of understand what you are saying that i shouldn’t convert the Tags Array into a single Array but after that i am lost.

Would you be kind enough to elaborate and guide me through this?

Yeah when you are actually spawning the new spiders you want to do it based on whats in your array already. So do a for each, get the value of the tag and then add it to the tags on the newly spawned object.

Why bother spawning new spiders at all …

Since you already have an array of them just turn the renderers and collisions on and off.

You are half way to doing object pooling, you may as well go the whole way now and save the hassle of creating and destroying objects, Stops the GC kicking in when you dont want it to.