Get All Actor of Class called once but still slowed down the game

Hi, I have been testing with the “Get All Actors of Class” node. And noticed some serious slowdown. I am aware that we shouldn’t be calling his function frequently as it is an expensive operation, but in my test, I have only called it once when I pressed a key but the slow down still occurs. I have used it to query the basic third-person character and the PlayerStart class and the resulting frame rate I got is as follows:
When I did not call the function:
80 FPS, 12ms
When I call the function with just the player-controlled pawn:
32FPS, 31ms
When I called the function with one other pawn in the world:
25FPS, 40ms
When I called the function with nine other pawns in the world:
10FPS, 98ms

Test with querying the Player Start:
When I called the function with one Player Start:
68FPS, 14ms
When I called the function with nine PlayerStarts:
36FPS, 27ms.

Am I using the function wrong? Do we need to deliberately stop the execution every time we use this function?

Thank you very much.
Chun

@DigitalRider This is arguably one of the engine’s slowest functions though, as it is checking everything in the scene, as practically everything is derived from the Actor class. I’d recommend using it very lightly because it is not recommended on the docs to use it for multiple frames. You’re not using it wrong, persay, but you might be able to refine what you’re looking for.
I hope this can help!
-Zen

1 Like

That sounds strange! What kind of hardware are you using?

GetAllActorsOfClass just iterates through all actors in the world - even if you have 10’s of 1000’s or more it shouldn’t slow your framerate by that amount - It sounds like something else is happening too…

Thank you for your response. I attempted to narrow down the criteria by specifying the Actor Class. Is there anything else I can do to refine the target class?

I am using an AMD Ryzen Threadripper 1950x with 32GB ram and a GeForce GTX 1080Ti.

The project I am testing with is the starter third-person project with default everything. And the only function I called is the image I posted.

No there must be something else going on in your project.
I just created a starter third-person with default everything and called it, no slow down - I called it from Tick (60FPS) and it still didn’t slow down…

1 Like

Thank you very much for trying it out. I am not aware of anything else going on in my project. I have just asked a co-worker to try it on his side and it worked fine for him too. I guess I am going to try my best to narrow down what is wrong on my work station and I will report it back if I find anything.

1 Like

I looked into the plugins and compared them with my coworker and the only difference is the Bridge(Megascans Link for Quixel Bridge) plugin. I went on to disable it and test the code again and the slowdown did not happen again! I wonder if this is just my bad luck or does it happen to others too.

I’ve got Bridge installed and tested it by opening it and running again - no slowdown. perhaps it was corrupt in some way on your machine…

Which version of Bridge is on your machine?

image

Thank you for checking. I didn’t want to accuse Bridge for things they didn’t do wrong. It looks like the game slows down when I use “Watch this value” on the output array in my character BP. Once I close the BP or stop watching the value, the FPS seems to get back to normal. I feel bad to ask you again, but can you check on your side and see if you observe the same behavior?

I tried adding a watch to it (I already had the blueprint open) - no change, added an array of actors variable, assigned the result of the GetAllActorsOfClass to that and watched that value as well - still got the same framerate.
Having said that though, in UE5 I’m forever finding things starting to slow down, and closing any open blueprint or static mesh editors seems to fix it so this is starting to sound like the same issue.

1 Like

In any case, thank you for guiding me to find a solution to my problem. Much appreciated.

2 Likes