i am trying to call it from another two blueprint, it updates the array in one blue print but not updates in other blueprint, i am doing the same method in both, can you say where i am wrong, thank you.
So… I’m a bit confused by your question, if you could elaborate. For instance you say this is working, but it shouldn’t, as if the actor is destroyed, the code stops there.
Your code snips would be fine, however it looks like your dispatchers are headed all over the place. If you could specify where each of these code snips come from (BP Enemy, BP AI Spawner, BP Top Down Character) that would help.
Honestly, it seems like this array is getting copied around left and right- it might be a good idea to just put it on the Game Mode, and call on the game mode to update or get that array. That way, anything that needs it has access to it, and it only has to run once to update the array for everything that needs it.
i see your point, i just realised that but it works and if flip those it will be a problem because i get the enemies before that one destroy so that enemy will include in my array.
To summarize, i have a BP_TopDown blueprint that involves Enemy array which i update it with get all enemies function in that blueprint and i want to call that function whenever an enemies dies or spawns. Working example snippet from enemy blueprint when it dies and other one snippet from BP_AI_Spawner blueprint that spawns enemies. If you need more information about blueprint feel free to ask.
See, what you’re doing here is very heavy on resources- get all actors is great once or twice but this will likely become excessive and slow down your game processes. In essence, it’s not scalable.
SO yes, I recommend redoing this system. Put the array and the original “getAll” in the game mode with a .2s delay node right before it (to ensure everything spawns in first).
THEN what you’ll do is- when you want to remove something, you GetGameMode-> cast to your gamemodeBP-> drag off the blue node and GET your array of enemies → REMOVE. And if you want to ADD something you use “AddUnique” because it will only then add it if it isn’t already in the array.
You really only want to use “GetAll_OfClass” when you have an empty array, because it scans EVERYTHING in your level every time. "GetAll"s are generally used during loading screens only, for this reason.
So say, your enemy is defeated by the player. You will do the above (get gamemode, get array, remove) on the node right before “DestroyActor” and boom! It’s the same processing power as roughly scanning 1 thing in the environment, as opposed to all of them. Efficiency!
You CAN keep going the way you’re going but I’m telling you… It’s really going to hurt you. And to be honest I don’t know how to help you keep it going. All the dispatching looping around somewhere is likely the issue here.