Performance question (blueprint communication)

Hi,

I wonder how bad for performance it is to get a reference to all actors you need from a particular blueprint at begin play using “get all actors of class”?

Like I know that you should use “get all actors of class” as little as possible, preferably never even. But say that i just use it once on begin play in each actor blueprint I need a reference to a certain other blueprint. Would this still be considered a bad idea?

If yes, then what are the best ways to approach this?

I’m making a game in which i have a lot of interactable objects. Such as doors, light switches, generators, traps, … All of these specific types are inhereting from an “interactable” class which has a function “activate”. Now depending on which object the player is interacting with this “activate” function will do something different and specific to that particular type of object. Like a door will open and close. A light switch will activate or deactive a light and so on…

That and secondly, how would I go about passing info to the HUD. Like the HUD needs to display what type of object the player is looking at.
Now I already have all of this working. And it’s working quite well. But right now I’ve been using too many “get all actors of class” nodes and I wish to optimize my game as much as possible. So what are some possible ways to do this?

Thanks!

I tried to use 4x “get all actors” in tick on map with ± 100 actors :smiley: without any lag…
That node shouldn’t be used in tick, but on begin play or some events its without any problem…

To be honest, I don’t get why and where you even need a single GetAllActorsOfClass node. I would assume you’re sending a line trace each tick and check if the trace hits an actor. If it did, you try to cast it to your “Interactable” class. If that is successful, you can access any kind of string / name / text variable from that class. And then within your player character you send that variable to the HUD to display what type of object that actor is. Where do you need the GetAllActorsOfClass node?

In my project i needed “get all actors with tag” for node “apply radial damage” to input “ignore actors”… <- is it ok?
But i think i will use “get overlapping actors” instead and filter tags.

Cool! Yeah I already knew that using it on tick is probably one of the worst things you can possibly do. Haha!

But I’m still wondering if there are better ways to do this. Like I’ve heard talk about using interfaces and stuff. But I don’t seem to understand how to use these for passing values around. Like they seem to be used mostly for functions. Which could definitely work I guess. But for my HUD I mostly need to pass values to it.

The detection of objects currently happens with the use of my melee collider volume. Which is a box volume in front of the player. It basically detects everything from enemies to interactables. What I currently do is save the overlapping actor in a reference and use that to do stuff with it. Which is perfect. So I’m not using “get all actors of class” here.

But I’m using it on other stuff such as passing info to my HUD. Like when I get hit. I pass my hp to my HUD using “get all widgets of class”. I could change this by saving a reference of my HUD at begin play. But what other ways are there that I can use to communicate to my HUD from within the player?

Save the reference and everything is fine, no need to change anything more.

Ok cool, thanks then I will do that. :slight_smile: