I have created a basic AI (This one → [UE4 Wiki][1]). And as shown in the images, it has a massive impact on the performance after placing circa 30 low poly AI. How can I drasticly improve the performance?
Just to make sure, have you isolated that it’s the AI logic that is causing the performance problems? E.g. if you set the controller to the default AIController and spawn 30 of your pawns do you still experience low fps? You can also use “stat DumpFrame -ms=0.1” from the documentation to get a better idea where the CPU time goes. It basically shows time and the call count for different methods.
Otherwise provided that your hardware is good enough it sounds like it should be reported as a bug or maybe a feature request since you’re taking the example straight from the wiki.
I’m not really sure what my be causing the issue but a drop to 28 fps sounds like there is some other problem as well apart from the AI. The default AIController does nothing basically. Still sounds very expensive though to run the behavior trees.
With risk of stating the obvious, make sure you run “stat DumpFrame -ms=0.1” when the game is running. Otherwise I don’t know what the problem with that command would be.
How can I be sure that I ran stat DumpFrame -ms=0.1 correctly? The FPS does is not changing when stat DumpFrame -ms=0.1 is entered in the commandline wile running the game.
The stats on the screen clearly show that the cause of your fps drop is character movement. I’m surprised it’s that much to be honest, but nonetheless that’s your cause. There’s couple of things you might try. First of all see if you really need CharacterMovementComponent for our AI. It’s pretty expensive, raw PawnMovementComponent is a lot cheaper (but has less features as well).
Upcoming 4.8 is shipping with “navmesh walking” as a optional character movement mode. This is a lot cheaper, but requires you to have navmesh on your maps, and it’s quality is only as good as your navmesh’s precision.
One other thing, you might want to disable overlap checks for your pawns (set GenerateOverlapEvents to false it pawn’s components). Overlap checks do show in your perf stats as well.
Hey Mieszko, you mentioned a raw “PawnMovementComponent”, sounds really interesting, but where is it? I can’t find it… Profiling tells me that the Character Movement Component is taking 650ms, so it’s a bit too much I think, and I don’t need many features, no jumping or anything else fancy, just being able to move from A to B and use the navmesh to find the path. I only have 300 AIs at the moment, I would like to get it smooth, and 650ms does not look smooth
“that big” is relative to the machine its running on. It hasn’t improved really that much, I have done some extend testing on it in recent versions.
400 AI’s
Without AI: 11MS
Without Movement: 14.5MS
PawnMovement: 18MS
(acceptable performance, but the
quality is not suitable)
CharacterMovement: 28MS (Bad
performance…)
CharacterNavmeshwalking: 27MS
(literally just as bad)
In conclusion I’m still looking for a suitable AI_Movement Solution. I hoped the MOBA AI Twitch stream would give some improvement tips in that regrads, but when I saw they just used plain character movement I quit the stream.
I’ve noticed that character movement component is just not viable for large numbers of AIs as well. It’s fine and dandy if you just want to have a couple guys running around, but for anything large scale you need an alternative.
I’ve been looking at custom variants of the ‘floating’ movement component for my game , (as it is mostly underwater) but I can see it turning into abit of a rabbit hole if I want to have my pawns also walk on land , etc.
Epic, can you make a less expensive variant of character movement for large scale AI use? pretty plz?
We have an average of 200 characters at one time in Paragon, and we don’t experience huge perf hits. Using navmesh walking is the key here but it works only if there’s navmesh where AI is moving.
Is there a viable way to calculate the path (with path finding) on a separate thread and once having the path(points array I suppose) to feed it up to the AIController to narrow down the Pathfinding calculations ?
I would be very curious to see your setup that has 200 performant AI. I have stripped everything down as much as possible and 200 AI seems to cost about 8ms. Could you list out the key setup elements that allow for this performance?
I am in the same situation. 30 AIs and my game is done. An AI movement tutorial, article, even a sentence about how to go about getting 200 AIs on screen using navmesh would be great for relative newcomers like me making Twin Stick shooters etc
I am in the same situation as well. Really need to spawn around 200 AI characters roaming around the level to give the environment a crowd feel. Any guidance in this direction would be appreciated