I’m heavy into blueprinting at the moment, and i understand the “Get all actors of Class” node is a little heavy. It seems to work find on the projects I’m working on currently, I was just wondering if there was a cleaner or less memory intensive way to do this?
I’m mainly using this for interaction with blueprints, switching materials, colours, lights etc.
It IS intensive. To get round this, you need to store an array of the spawned blueprints (usually in the level BP, or the player BP, depending on what the listed BPs are), and then loop through it. You need to keep track of when to add to, or remove from, this list, but the overhead is massively less than GetActorsFromClass.
The overhead of GetActorsFromClass comes from it looping through ALL the actors in the game, and returning an array where the class matched. If you create the array and maintain it yourself, the game doesn’t need to loop though all the Actors, and you save yourself the massive number of operations required to do this every time your reference it.
I have a ‘Door BP’ in which I reference 4 keys. Each key is a separate BP used to unlock instances/copies of the ‘Door BP’. For example, ‘BP Door Key Front’ is used to unlock the instance of ‘Door BP’ named ‘Front Door BP’. I have used ‘All Actors Of Class’ to reference each Key BP inside my ‘Door BP’ (see pic). This works but have a feeling using an array might be more economical, but have no experience using arrays. If anyone knows what type of array I would use and how I use it, that’d be great. Thanks.
• to start with, the keys should be the same class
• each key is an instance of the class with some variable that differentiate them (which key opens what, for example)
• how to organise and reference it all depends on scenario
We’d need to know what is supposed to happen, what the garage is and where the keys are and how it’s supposed to work.