Fixing navigation of multiple StaticMesh-based characters
Since I am currently stuck in the development of my RTS game, due to the navigation issues, I decided to create this thread even though I bothered many people with my other questions closely related to the heading matter :) I think that perhaps this post might become handy for others as the other threads I created are slightly disordered and confusing. I would also be glad to receive a final feedback whether this problem can be resolved using UE4 or it is just so incompatible that I should let go with the idea. Hopefully, the former is true, because I have put a lot of effort in some of the algorithms in the game (like actor combination) and naturally would not like it to go to waste. These are the links to threads outlining the problem origins (chronologically):
At present I am using the @Justin.Dooley setup of the characters, but it does not support the addition of new StaticMeshComponents to the characters, because the collision is based strictly on the root's capsule component. Then there is the idea from @MieszkoZ which defines the characters as navigation obstacles. I will briefly describe the setup I implemented for this concept and its outcomes (a copy-paste from one of the comments):
1) In the Navigation tab of my StaticMesh asset (used in the character blueprint) I add a cylinder collision mask.
2) I set the AreaClass for this collision mask to a blueprint NavAreaForPaths I have created.
3) I set the radius of the cylindrical mesh to 15 (50 is the length and width of the StaticMesh)
4) In the NavAreaForPaths blueprint I set the default cost value to 5 and the entry cost to 2.
5) In the StaticMeshComponent of my character' blueprint I change the CanEverAffectNavigation Property to true, so that the character is affecting the NavMesh increasing the path cost around itself.
And all of this sometimes works and sometimes does not. The characters clearly want to avoid one another. Nevertheless, they often follow a path which leads through the expensive NavArea, thus when a character reaches a path point located in such Area and consequently the NavAreaForPaths of one character starts to overlap with NavAreaForPaths of the other character, the character that is being navigated becomes enclosed in the expensive NavArea. Therefore, it no longer cares if the path leads through the costly area or not. It then wants to shorten its movement distance, which frequently results in a collision of the characters. I have also tried multiple setting of the path costs in NavAreaForPaths blueprint, but setting the default cost to a too high value (which completely prevents the path points to be generated in the highly expensive NavArea) results in shaking and irregular rotation of the characters (as they are located in the very expensive area all the time, because they generate it and thus start to do weird things). However, any lower value than that, makes the path points sometimes be created too near the character resulting in the above-mentioned overlap problem.
I am really desperate to find the solution to this problem, so that I could continue the work. It does not have to be a very efficient one, because there won't be enormous numbers characters in the scene during runtime (about 50 maximally).
I am really thankful for the help I have received so far, but need slightly more advice to close the case once and for all :)
Follow this question
Once you sign in you will be able to subscribe for any updates here