I’m trying to figure out the best way of populating the streets and some buildings with super simplistic AI just to bring a little life to the environment. So far I’ve created an AI blueprint that uses event ticks with delays and some simple logic to find waypoints that I’ve placed all around the place and to find a different one if they get stuck trying to get to it or they reach it and stop. And that works reasonably well with a few dozen actors, they don’t get stuck on each other too much and they seem like they’re actually wandering about and not just randomly swapping direction mid stride.
Just a glimpse at what they’re doing (nothing happens, they just walk):
This is much higher density than I want to have, just to test it. With lower numbers they are much less likely to get stuck on the stairs, but it’s still a bit of a problem.
For some reason, the AI’s are causing a spike that slows down my framerate every 1 minute interval. The more AI’s I have the bigger the spike and I can’t think of anything that would happen for all of them at exactly 1 minute intervals. They do all change move to waypoints between every 30-60 seconds, but that’s spread out with a random float between those values for each individual instance of the AI. But that’s barely noticeable unless I have well over 100 AI’s moving about. Which brings us to my next performance issue.
Running them all like this is somewhat heavy on the resources. There is little difference whether I’m using an animated skeletal mesh or a simple capsule moving around, so having lower LOD stuff probably won’t help. I don’t know if it’s the blueprint approach I’ve been using that’s inefficient or it’s just a thing that’s supposed to be slow. I can’t think of many games where you would have hundreds of actors moving about anywhere. The closest existing example of what I want to achieve that I can think about is Hitman: Blood Money Mission 6. Where there’s a parade going on in the streets which are full of what seems like hundreds of people. (https://www.youtube.com/watch?v=74svhYZGURc)
I’ll have to do some kind of culling and spawning of actors that are in visible range of the player, but I’m unsure what the best way to do that would be. Just off the top of my head, I’m thinking maybe either trigger boxes in the level that detect the player and “move” the population along with the player or some kind of giant trigger box attached to the player that deletes things that exit it and spawns new ones to maintain a proper number of actors in the world. So any better suggestions are definitely welcome.
And one final thing, even though my primary goal now doesn’t involve killing all of my wandering civilians. Is there any way to stop the event tick from trying to send any signals after I’ve killed it (ragdolled and stopped the animations on the character without destroying it)? I have tried running the initial execute line through a branch that checks if it’s dead or not, but it sometimes still goes through. (no idea how) And once the character is dead it doesn’t need to check if it’s dead or not every tick. I feel like that could be handled better.
Any questions, suggestions or ideas are very much welcome, it really helps to have others look at these problems from their perspectives.