Hey guys, here’s my query…
In my project I have my actors track and communicate with each other. To build a “target” list that an individual actor will use I “get all actors of class” at beginplay and store the output in an array variable. During gameplay as actors are destroyed and spawned i remove/add to the array to keep it up to date. So far so good.
Now what ended up happening is that more than one actor class has the same “target” list and I was calling the same “get all actors of class” from several BPs. Even though this only happens on beginplay it still is inefficient. Why store the same set of actors in 2+ separate variables across my project?
**I want to run “get all actors of class” for each of my actors once per level and store their outputs into arrays in a “master_BP” which each actor will be able to access and cast to. **
Considering how common place it is that “this is a slow operation” and “avoid using it every tick”, there is little guidance (as far as I could find) on how to best manage the get all actors of class node.
Right now I am using a UMG widget for this. Is there somewhere better to run this?
I tried doing this in the level blueprint, but I didn’t know you couldn’t cast to it. I tried in a custom GameState, but I couldn’t set it up properly and the game wouldn’t run at all. I tried in an “empty actor” that I place in my level, but I need to set him trough a “get actor of class” node whenever a new actor spawns to be able to cast to him.
With the widget I run a “get all widgets of class” in each actorBP on spawn and cast to it, which to my understanding is cheaper than “get actor of class”.