Group pathfinding

Hello guys I am back again with another questio0ns :slight_smile:

I am working on prototype in which I can select multiple units and then move them to point where I clicked (RTS style movement). However, I am experiencing/ed two issues:

  1. Detour crowds. New CrowdFollowing component works better than RVO which was unusable but there are some issues when two units are not moving and stay near each other and third is trying to go between them and gets stuck because moving pawn can not push these stationary pawns.

d7ed76a73c63b180157af3ea912f5e1c72bc8a50.jpeg

To solve this issue I decided to turn off crowd avoidance and whole collision for pawns so they can overlap now. It is not best solution, so If you know better one let me know.

  1. My main issue is that when I click somewhere I would like to move there group of units. I can not move them to same location because they will overlaping. I would like to calculate e.g. box formation 2x2 (for 4 units) and move there units. I think this is doable using project point to navigation but what should I do when pawns are near navmesh edge ? I was doing some tests and Get Random Point In Radius does exactly what I need because It respects navmesh edges but I would like to predefine position of these points so they will not be random.

I need to get back two locations which are out of nav mesh back to navmesh (possible little overlaping with other units will not be issue in this case)

I think I found workaroun for second question. I still use Get Random Point In Radius but I use it only when requested position is not reachable. This solution produces nice formation when units do not collide with objects and if they do then they will pick some other reachable random point in radius.

I use several custom blueprint nodes but most important one is recreated UDK function IsPointReachable(). I think It will be good to have function like this in official build because it is very useful.

Blueprint:

Video:

**
IsPointReachable source code (not final version of function but It works as desired):**

CustomAIController

h


UFUNCTION(BlueprintPure, Category = "AI|Navigation")
	bool IsPointReachable(FVector Point);

cpp



bool ACustomAIController::IsPointReachable(FVector Point)
{
	bool bFoundPath = false;
	UNavigationComponent* PathfindingComp = FindComponentByClass<UNavigationComponent>();

	if (PathfindingComp)
	{
		bFoundPath = PathfindingComp->FindPathToLocation(Point, NULL);
	}

	return bFoundPath;
}


Blueprints still need some improvements like traces against collision (so players will not go behind walls) and offset for formation to center it to cursor.