HaywireInteractive / OnAllFronts-Public

UE5 MilSim FPS / RTS Game (formerly ProjectM)
MIT License
118 stars 24 forks source link

[Avoidance] Fix soldiers colliding with each other when changing formation #188

Closed Leroy231 closed 4 months ago

Leroy231 commented 1 year ago

May want to wait on https://github.com/HaywireInteractive/OnAllFronts-Public/issues/920 before working on this. After it's done we should verify if this bug still exists and do the subtask below.


Watch this video for the bug (happens at 35 seconds): https://youtu.be/jveI9Xr8S5w?t=31

Steps to reproduce (use the shorter steps below when debugging):

  1. Start playing
  2. Go to drone (f key)
  3. Look at a squad and select it (t key)
  4. Keep changing formation (u key) until they go from diagonal formation to fire team wedge formation
  5. Observe soldier gets stuck momentarily:

Image

Steps to reproduce (short):

  1. Open L_Small_AvoidanceTest
  2. Start PIE
  3. Press v to go into 3rd person
  4. Wait for the soldier to walk into you
  5. If you want the debug helpers drawn as in video below, run ai.debug.mass.DebugEntity 3 and pm.UseDrawDebugHelpers 1. The red arrow is the avoidance force.

https://github.com/HaywireInteractive/OnAllFronts-Public/assets/108254625/76693023-490d-4466-8621-20b4cda13db0

If you move slightly off the path of the other soldier then avoidance works fine:

https://github.com/HaywireInteractive/OnAllFronts-Public/assets/108254625/a70ddbf6-d29e-456c-98e0-5b968cc4d659

If the still entity is not player controlled they use standing avoidance which helps a little (from L_Small_AvoidanceTestNoPlayer):

https://github.com/HaywireInteractive/OnAllFronts-Public/assets/108254625/ab73df73-4283-4258-99fa-ac4005cadb13

Instead of getting stuck momentarily, soldiers should move around any others nearby. Here's an example of what that same avoidance code produces in City Sample:

https://user-images.githubusercontent.com/108254625/224178067-b298a163-f99a-4eb2-ab35-b86e1cff9731.mp4

The logic for avoidance comes from UE source code here: https://github.com/EpicGames/UnrealEngine/blob/d9d435c9c280b99a6c679b517adedd3f4b02cfd7/Engine/Plugins/AI/MassAI/Source/MassNavigation/Private/MassAvoidanceProcessors.cpp#L719. It has already been copied into our codebase since we made some minor changes to it previously. But the bug exists in both versions of the code.

Things we've already tried but didn't help with fixing the issue:

  1. Tweak the avoidance parameters in DA_MassSoldierBase: Image
  2. Modify the avoidance code. It exists in our codebase at https://github.com/LeroyTechnologies-Org/ProjectM-Private-Staging/blob/e58e53ff3c80c50631cc13bbbca5d6e530b54bd1/Source/ProjectM/Private/MassFastAvoidanceProcessors.cpp#L71. We have a PR which fixes this issue, but it introduces other regressions: https://github.com/HaywireInteractive/OnAllFronts/pull/19

Other things to try:

Leroy231 commented 1 year ago

We have a PR which fixes this issue, but it introduces other regressions: https://github.com/HaywireInteractive/OnAllFronts/pull/19. Next step should be to check why we can't reproduce this issue in City Sample by narrowing down the differences.

Leroy231 commented 5 months ago

For a more recent commit with the PR above (with some different logging) see https://github.com/HaywireInteractive/OnAllFronts/commit/a488b568db61720cb6ef7b2538819446de781f20

Leroy231 commented 4 months ago

Fixed with recent Mass Crowd Detour movement.