Hi guys, I’m currently working on a game with a really spectacular coder friend, but since neither of us are particularly experienced with the ins and outs of ue4, and there isn’t any documentation, and google is defeated, I’m coming here. I’m wondering. Is it possible to do a Hivemind AI with UE4? At the moment we’re being stymied by the number of bots we have to spawn and it’s murdering the framerate, like 15 fps or so. I’m not so concerned about that, but we’re at the limit of where to optimise and I suggested a Hivemind style AI where you have a central processing point that calculates the goals and tasks needed and then sends out mindless drone units to do its bidding. Sorry for the lack of technical speak, I’m a graphics guy.
Anyway, I can’t find any examples, documentation, or anything really, so I’d like to ask the brilliant people out there. Is it possible in Unreal? And if so, what should we be looking at? The current system of calculating everything at the pawn level is really awkward for the number of AI units we need to spawn and we don’t really have Rama’s genius to make something brilliant and multithreaded and dynamic like he did. We keep knocking against unreal’s structure without really understanding it.
Fyi, we’re making a fps dota like game. So everything needs to be replicated over the network, which again makes Hivemind ideal at the server side.
Simple way would be to create a very simple AI for the pawns, with another pawn telling the pawns simple commands for what it wants them to do. This would be the easiest to do. The problem with spawning a large number of actors into the level at once is the AI, as even if they are off screen the AI will still be running. Now you could make it so only when you are in a certain radius that the AI runs. Or only have the AI running once in a while when outside a certain distance.
We’re already spawning about 48 units, not counting the ten bots per side, so in total, you’d have 67 AI units if you fill up the bot rosters and have the one player. I know how expensive it is, and we’ve already shaved pretty much everything off the AI, at the moment the minions are just basic pathfinders travelling between nodes and hitting each other. They barely aggro at all. Basically, we’re already doing what you said. It’s too expensive and we need more sophisticated behaviours to fill out later features.
Ideally, I’d like to have an overhead range. Essentially have the AI able to spawn around 100 to 200 units on the map.
The fps is a bit of a concern for us as we’re using a lot of expensive features in ue4. it hovers around 40 to 80 fps, but if you go fullscreen, that halves. It depends on whether we’re running in the forest, which has quite dense foliage and there’s a lot of alpha overdraw. Fully dynamic lighting, and so on. Although, I have noticed. When you move, the fps drops about 15 frames, then, if you sit still, after a second or two it zips back up again. At the moment I have no idea what’s causing it, since it’s not isolated to location or what’s in view. It’s also just during play, as opposed to in the editor.
I should mention, I’m happy for tips and methods for best practices in UE4 AI. Our coder is inexperienced, but very good at solving problems and figuring things out. He just needs a solid direction to go in and knowledge of how the engine works.
Hrm. That’s certainly helpful, but there’s 60ms unaccounted for. Most of the scene is computed in the ms teens. Which lines up with what I’m getting in editor.
GPU load is high, but it’s not going above 90%. It’s sort of jumping between 60 and 80% mostly. Memory usage caps at 1245.
We’ll solve it eventually, it’s likely something we’re missing in the post-processing, or calculations somewhere. Back to the question at hand, is it possible to make a Hivemind with UE4? I’ve noticed a lot of the AI controls are locked to the individual pawn, which seems inefficient for large groups doing the same thing. Is there a way to have AI act in a heirarchy with a central AI doing most of the heavy lifting?
Yeah just create a hive actor which has an AI and a bunch of pawns it’s controlling. the hive AI finds the target or where all the pawns should move to or action to do. Then send out that action to be run on the pawns.
I’d be quite surprised if the AI decision making itself showed up on your profile. The pathfinding might well do if you have RVO switched on I guess. Can’t imagine the behavior tree’s themselves would be any issue for performance (they are event driven), unless you’re doing lots of blueprint based calculations per frame, which I’ve found kills performance faster than anything.
@DarkHorror: Genius! That can definitely work… wait. Unreal defaults to a one to one relationship between controllers and pawns. Is there a way to change that so most of the calculations are being done by the Hive AI, with very basic stuff to let to pawns it controls do the things they’re asked to. I’m guessing we have to make a custom AI class for that and parent the pawns to it in some fashion. So they essentially act as children of the Hive Ai and repeat everything it does until told otherwise.
@zoombapup: Really? I should probably check how much where ticking per frame. There could be quite a bit, especially for collision volumes. AI has always been tough with unreal. I remember UE3 and UDK days having just as much trouble with the base AI. You usually had to use some kind of crowd actor or build your own if you wanted to spawn more than 15 AI and not have the performance chug.
Sounds you are GPU bound. Try open the console and type “stat unit”. What does it say? If GPU is higher than Game you are GPU bound, which I would highly suspect from your description btw.
Hrm. Game is the same as Frame and GPU. During editing there’s a difference. GPU is the highest. Draw is really low, which is nice, it hovers between single digits and teens, which makes sense, Almost everything is instanced and most of the calls would be LOD. The other stats are really high. There’s also the huge fluctuation between moving and stationary, the ms are doubling and tripling between when you’re moving and when you’re stationary. I think we’re bottlenecking the cpu somewhere. We should probably look into multi-threading more things. Thankfully our coder has done that kind of thing on a previous project, but it’s more complicated with unreal when you don’t have to write everything from scratch.
You could just create an array of pawns in the hive AI controller, and loop through those actors to send them what you want them to do, or have event dispatchers in each of the pawns and have it reference to a Hive AI controller and assign the event dispatchers you want that pawn to respond to.