if the target location is outside the navigation path, AI wont move even when the allow partial path is on,
We understood that “allow partial path” means that the AI will find the closest point if it “can’t” reach the target point! Is this what “allow partial path” supposed to do ?
Just to confirm, AI is working if the target path is inside navigation systtem.
Ok guys.
Good news.
I’ve taken a look and after an hour we’ve got a workaround.
I’m really salty that Epic leaves such issues unsolved for 5 years, blocking some of us folks for good.
It seems that any FAIMoveRequest requests are using bRequireNavigableEndLocation set to true, and bAllowPartialPath is checked after the path search fails because of EndLocation being out of the navmesh. So the logic is ill-formed.
I don’t give any guarantee for this workaround, do it on your own risk.
Add MyProjectAIController.h and MyProjectAIController.cpp to your project C++ codebase (or use existing AIController class if you have one).
Paste the code from below.
Add “AIModule” to PublicDependencyModuleNames or PrivateDependencyModuleNames in .Build.cs file.
Set MyProjectAIController class as a parent of any blueprint AIController you’re using in the project.
#pragma once
#include "CoreMinimal.h"
#include "AIController.h"
#include "MyProjectAIController.generated.h"
UCLASS(Blueprintable, meta=(DisplayName="MyProject AI Controller"))
class AMyProjectAIController : public AAIController
{
GENERATED_BODY()
public:
/* BEGIN AAIController interface */
virtual FPathFollowingRequestResult MoveTo(const FAIMoveRequest& MoveRequest, FNavPathSharedPtr* OutPath = nullptr) override;
/* END AAIController interface */
};
MyProjectAIController.cpp
#include "MyProjectAIController.h"
#include "AITypes.h"
#include "Navigation/PathFollowingComponent.h"
FPathFollowingRequestResult AMyProjectAIController::MoveTo(const FAIMoveRequest& MoveRequest, FNavPathSharedPtr* OutPath)
{
if (MoveRequest.IsUsingPartialPaths())
{
FAIMoveRequest moveRequestFix = MoveRequest;
moveRequestFix.SetRequireNavigableEndLocation(false); // fix AI not moving when end point is outside of the navmesh.
return Super::MoveTo(moveRequestFix, OutPath);
}
return Super::MoveTo(MoveRequest, OutPath);
}
I did it so the workaround will only work if you set “Allow Partial Path” to true when doing a MoveTo request. I didn’t want to deal with any corner cases which may occur in any other setup.
Set MyProjectAIController as a parent instead of AIController in blueprints: