AI group walking issues

Hello, I’m making a game where many AI character have to follow same point. The problem however is that they collide with each other, and when they get to a certain point, the AI characters that were behind others, remain there, instead of walk around others to get to the side.

I have tried both RVO avoidance and crowd avoidance, but nothing seems to really work. All I have is a dead simple AI character with a collision capsule that uses MoveTo to walk towards a certain actor. I don’t know many settings I can tweak, but the ones I’ve tried to are the RVO avoidance consideration radius as well as weight, and crowd manager, nothing seems to even get close to what I want. RVO seems to work worse than crowd avoidance, even though in crowd docs they say that it’s the same, but it also includes obstacles like walls.

The characters have rotation rate Z set to 720, and the rotation is following the movement.

There are many problems with all this:

  • Characters get pushed away which usually makes them fly when someone is walking into them from behind, but the character doesn’t have room in front of it to walk into as there’s some other character that has already reached the destination (or also is stuck in front of someone) or they’re trying to rotate.
  • Characters try to rotate both ways quickly, resulting into not really moving anywhere, which also makes the first problem even more amplified.
  • Character do not even try to rotate despite the fact that they cannot move forward.

In this example there are many characters on each side that are going against each other, which doesn’t seem to be big of a problem, but as some of them (the first ones) reach the goal, the others are simply stuck, trying to do something.

Also, the log is full of warnings like LogCharacterMovement: Foe_Fishman_C_11 is stuck and failed to move! Velocity: X=-29.67 Y=-26.82 Z=0.00 Location: X=1771.20 Y=571.74 Z=120.60 Normal: X=-0.96 Y=-0.08 Z=0.28 PenetrationDepth:5.288 Actor:Foe_Fishman_C_14 Component:CharacterMesh0 BoneName:fishman_index01Left (31 other events since notify)

Does anyone have any suggestions with all that?

Switching UCharacterMovementComponent::DefaultLandMovementMode to from Walking to Navmesh Walking fixes the pushes, however the character that are behind are stuck regardless

After a while I’ve found a solution that works for my project. In my game there will be a lot of enemies, like hundreds, and they don’t have to be really smart, they can be slow to resolve the walking issues.

The solution I’ve found is directly from Dungeon Defenders 1, and it’s pretty much the same, but with custom tools, as Unreal 3 (the engine the game was made with) had things (native finite state machine) UE5 doesn’t natively have anymore.

That’s how AI behaves using theirs solution:

Explanation

When AI walks into another while the speed is below a certain value (in my case 40) the AI will enter MovingAroundBlockade state, that tries to walk either left or right side relatively to the hit normal if certain conditions are met. For instance, the AI should’ve not be moving around a blockade in some time (like 2.5 seconds), or we’re not already moving around one and others. After at most 4 seconds the AI will abandon the MovingAroundBlockade state, and return to Seeking state, which seeks for a target.

For better explanation download Dungeon Defenders Development Kit from Steam, and check DunDefEnemyController.uc and DunDefEnemy.uc under Dungeon Defenders/Development/Src/UDKGame/Classes.

Or

Try to understand what I’ve transcribed in UE5 (it still lacks many docs, but it has some) :smile:

MTD_FoeState_MovingAroundBlockade.cpp - Pastebin.com
MTD_FoeState_MovingAroundBlockade.h - Pastebin.com
MTD_FoeCharacter.h - Pastebin.com
MTD_FoeCharacter.cpp - Pastebin.com

Some more illustrations, with different positioning, move speed and with/without debug drawings

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.