Herd AI

I’m making a game for a client and one of the proposed concepts involves spawning a random number of Manatees that swim together, and players need to be able to correctly count the Manatees. The Manatees should swim together, but not hit or pass through each other. I know RVO avoidance works great for walking characters, but I’m not so sure for swimming, nor am I familiar with UE4’s AI setup. I tried so hard to learn about AI from multiple tutorials, but most of them are about basic walking to locations on a navmesh, and many of them are either confusing or do not result in successful AI. If anyone knows good AI procedures for handling swimming animals in a herd, especially any AI that can allow the herd to split and regroup, that would really help.

I do plan on using basic static meshes for the animals. Manatees generally don’t move much so using vertex displacement instead of bone animation can be a fantastic optimization.

Look into EQS querries.
Then split task into 2 parts: finding desired spot in flock and getting there.
Finding spot, for that EQS querries are best.

Also great articles (and keyword to search) is : BOIDS

Um, wouldn’t that be a massive waste on resources since the manatees are going to be swimming not just side-by-side, but on top of each other as well? Is the desired spot one location for all the herd to follow? I’m sorry, I just don’t follow what I should do to get this to work from scratch. AI is the one elusive aspect of UE4 that I can never quite wrap my head around.

OK, so I made a rudimentary version eschewing UE4’s traditional pawn and AI movements for a custom code involving ticks, timelines, random locations in range, and a proximity check that will automatically push manatees away from each other if they come close to each other. Unfortunately, this custom coded version does not handle rotations very well. It would be nice if I can have the Manatees turning as they swim away from each other, the same way velocity particles work to align themselves according to their forward motion. Any help on the actual implementation of AI like this will be great. It’s one of the few things I have trouble understanding in UE4.

Sounds like something to be made into Flocking AI plugin and releasing it on Marketplace :wink:

Well, if you want your animals fixated in one direction while strafing left and right, then I’m certain my current custom solution would work well for you. My attempts to rotate them towards the direction they’re moving ended up with wild rotations every tick. For some reason, RotationFrom[X/Y/Z]Vector doesn’t work well with arbitrary ticked movement. This is why standard pawn movement/rotation would work much better, if I can get it to work. Any help would be appreciated.