What part of this BP is slowing down the game?

When I run my game with 20 elements in the array this blueprint causes huge performance issues, what could be the cause? This doesn’t seem to be that intensive to me?
Any help is greatly apreciated!

The turret is setup in a way such that the “cannon support” is attached to ground and the “barrel attachpoint” is attached to the support. the support controls the yaw and the attachpoint controls the yaw of the gun.

Are you running that in the weapon blueprint itself? So is the weapon rotating itself or do you have a separate blueprint that holds references to all your weapons and rotates them. How often are you calling that function? On tick?
If that is located in the weapon blueprint, then you actually have 20 turrets and they each are told to create an array with 20 actors to rotate. If that is the case you have 20 arrays with 20 actors each being told to rotate which depending on how often this function is called could be an issue.

I call this function once per tick from a pawn that owns the turrets, so the turrets never call this function themselves. But do you agree that this blueprint should be pretty cheap to run, except if I have a lot of turrets of course?

So 1 turret has 20 attachments that rotate and those are all stored in the array? And you only have 1 turret in your level?

No, I have one pawn which has the array of turrets, and each turret has two components (the ones you see that I set relative rotation on)

It should still be fine. There has to be something else going on. It’s either too much to process or too much to draw. Are you sure the bottleneck is the CPU and not the GPU?

In console (~ key) type in command “stat game” and “stat slow” which will give you time of how much each step of frame composition take and see what causes the slow down. Note that if you run something on tick you only have 16ms (most likely less then that) to maintain 60FPS and blueprint (at least in editor since you can turn nativisiation in packaing) is 10x slower then native code, so looping array on tick with blueprint is costly. Also check if you don’t do any other heavy operations like Get All Actors of class and such on tick.

yeah I’m sure but here are som screens:

https://i.imgur.com/K6EZTaV.png (the top row actually disappears after a while because the tim becomes to long)

(the reason it says that I move 200 components is because I increased the number of turrets to 60 to easier see performance issues)
But as you can see, it takes like 1ms per rotation? does’t that seem unreasonable as hell?

I really can’t figure this out…

okay I tried som profiling commands and here are the results:

https://i.imgur.com/K6EZTaV.png (the top row actually disappears after a while because the tim becomes to long)

And yeah I know that you preferably shouldn’t do stuff on tick but I kinda have to handle their rotation in some way right? And no, I don’t do anything like cast or “get all actors of class” every tick.

So the answer was simply that the turrets were to close to objects that they are collision checking against, disabling their collision against those objects worked wonders.