Hi, in the game/project I am working on soldiers spawn automatically every few seconds. After spawning, they follow a path defined by a spline from the right of my map to the left. Currently, that is all they do. However, once about 40-50 units have spawned (they all remain in the game) the performance noticeably decreases and hits below 10 fps. This annoys me a little, and while this does not affect development currently, because this number is so low, I would like to get an idea now where the issue comes from to eventually solve it.
I used the stat game command to assess what causes this and noticed that this drop is due to “world tick time” and “tick time” and (now) less due to the movement component we are using.
The problematic values rise with each spawned unit.
I already deactivated all tick events I found in the soldier’s blueprint class, which helped alot. Yet, the performance still decreases way too fast. Eventually, I would like to allow for at least about 300 units and okay performance.
I tried to use the session viewer to profile the game and figure out what exactly causes the drop. Here are two snapshots showing what the Session Viewer showed
I am not too familiar yet with profiling the unreal engine. Do you have advice on what to profile to figure out the precise cause? To me, these results show that most time is spent waiting.
To give more background:
This is the soldier’s current behavior tree:
I do not know how to post blueprints, so I will describe the rough content of each task:
Select_Lane:
Checks if the lane is set. if it is set, it returns success immediately. If not, it gets all actors of class BP_lane and iterates through all spline points. For each point, it computes the distance of the soldier to each point and then decides which point is the new target location.
UpdateTargetLocation: Checks whether the soldier reached the current target location.
This just uses the current location of the soldier and the current target location and computes the distance of these points. If it is smaller than the acceptance range, the next point of the spline is the new target point.
MoveTo: Obvious.
Wait: Obvious.
These tasks should not take alot of computational ressources. So I do not really know what to look out for.
Any help is appreciated