Delete Actor But Keep in Array

Hello Black2Own,

I guess you just want to store data in the array the player holds, in your example just the name and years, not the actors themselves. I suppose you’re doing this in blueprint. By default if you create an actor array in blueprint you’ll create an array holding references to those actors, if you destroy the actors you’ll make the references invalid.

If you want to stick with what you are already doing; you can create a struct type and let each actor create an instance of said struct, which they’ll copy to the player, not the reference to the struct instance, but a copy, be careful though you don’t want to copy big structs or too many structs all at once, as this will cause performance issues. And let the player store this data, in an array of the type of the struct. And you would be able to recreate the actors with the stored data.

If you really want to store the actors you would have to copy them into the array, and have an array not of type of actor object reference but actually of type actor object, this may cause memory issues though if you have a big array and/or the actors are big, in terms of memory allocation.

But I think neither of those solutions are the most performant, nor the most elegant. But there would be many different ways to solve this problem.

Hope that helps. If I misunderstood you, just tell me, I’d be glad to help.

Regards,

Vecherka.

Hi Guys this question may seems complex at first but i will try to explain as much as i can.
Here is the deal i will explain with number and shapes so you can get it more quickly.

I have a “Sphere” witch on start generate 5 “Cubes” each of the cube has a random Variables in it (They are generated)
let’s say (Name & Years) (Name & Integer), and then the spawned actors cast to my player and add themselfs in the Array inside my Player “Actor”, when that’s done i want them to destroy themselfs and “Sphere” to regenerate them once again, and then the spawned actors cast to my player same as before Ex.
but i want my Array to keep all the actors with their (Name and Years) so when each time i use For each loop to get all the previous Name & Years.

Guys may i didn’t explain this correctly but i try my best if you have any missunderstandings i will explain a bit more
even i will upload an image so clear the things up more. i need serious help here thanks !

I get it, but I don’t understand what your problem is.

The spawned actors make entries in an array which is contained in your player. So when the are destroyed, those entries will still be there, no?

Sounds like you should use a map for this (called a template in C++). It stores a KVP (key and value pair). You also may want to look into setting up a structure, and/or an array of structs.

You need to spawn the actor each time from the struct. Otherwise, if you want to keep a soft-reference to the actor, you could try to capture it in a string version (using the “get display name” conversion for the actor). You can convert that back to an actor spawn, later, but at least you have it timestamped as a unique name.