Hello Friends. I’m developing a Latent Node for my game that simulates the AI Move To, but for a Root Motion type of movement. Due to this, I created a Class RootMotionAi and a RootMotionAiNode to connect this inside my Blueprints and Behavior Trees. However, I’m having a Issue for a while now. Everything work perfectly, but suddenly the game crashes with this error:
Assertion failed: (SharedPath.IsValid() && SharedPath->IsValid()) == !!bIsValid [File:D:\build\++UE5\Sync\Engine\Source\Runtime\NavigationSystem\Private\NavigationPath.cpp] [Line: 554]
There is no Strange behavior before the crash the Character is just walking normally and suddenly crash.
This is the part that the Code Crashes on the debugger.
This is my .h:
class THEFINALLIGHT_API RootMotionAi : public FPendingLatentAction {
public:
FString& InfoMessage;
ARTCharacter* Pawn;
UPROPERTY()
UWorld* World;
UPROPERTY()
AActor* Target;
UPROPERTY()
FVector Goal;
bool bAbort;
private:
UPROPERTY()
FVector GlobalGoal;
FVector NextGoal;
UPROPERTY()
UNavigationPath* NavPath;
FRotator RotationToFace;
UPROPERTY()
UNavigationSystemV1* NavSys;
int IndexPath = 1;
float AcceptanceRadius = 30.0f;
public:
FLatentActionInfo LatentActionInfo;
ECountSecondsOutputPins& Output;
RootMotionAi(FLatentActionInfo& LatentInfo, ECountSecondsOutputPins& OutputPins, UWorld* World, ARTCharacter* Pawn, FVector Goal, AActor* Target, FString& OutInfoMessage)
: LatentActionInfo(LatentInfo)
, World(World)
, Pawn(Pawn)
, Target(Target)
, Goal(Goal)
, Output(OutputPins)
, InfoMessage(OutInfoMessage)
{
GlobalGoal = FVector(0, 0, 0);
NextGoal = FVector(0, 0, 0);
RotationToFace = FRotator(0, 0, 0);
bAbort = false;
NavSys = UNavigationSystemV1::GetCurrent(World);
}
void DrawDebugPathLines(UNavigationPath* NavPath, UWorld* World);
void SetForward(ARTCharacter* Pawn, int value);
void SetActorRotation(ARTCharacter* Pawn, FRotator& RotationToFace, float DeltaTime);
void SetNewRotationGoal(ARTCharacter* Pawn, FVector& NextGoal, FRotator& RotationToFace);
bool CheckIfFinalObjetiveChanges();
bool CheckIfReachedNextLocation(ARTCharacter* Pawn, FVector NextLocation);
virtual void UpdateOperation(FLatentResponse& Response) override;
These amount of UPROPERTY are a hypothesis that I have that Unreal was nullifying my pointers.
And this is the UpdateOperation From my Latent Action:
void RootMotionAi::UpdateOperation(FLatentResponse& Response)
{
UE_LOG(LogTemp, Error, TEXT("bAbort: %s"), (bAbort? TEXT("true") : TEXT("false")))
if (bAbort) {
UE_LOG(LogTemp, Error, TEXT("ENtering on bAbort"));
Pawn->Forward = 0;
Output = ECountSecondsOutputPins::OnAbort;
InfoMessage = "Aborting";
Response.FinishAndTriggerIf(true, LatentActionInfo.ExecutionFunction, LatentActionInfo.Linkage, LatentActionInfo.CallbackTarget);
return;
}
if (!NavSys)
{
bAbort = true;
UE_LOG(LogTemp, Error, TEXT("Navigation System not found!"));
return;
}
if (CheckIfFinalObjetiveChanges()) {
NavPath = NavSys->FindPathToLocationSynchronously(
World,
Pawn->GetActorLocation(),
GlobalGoal,
nullptr
);
IndexPath = 1;
}
if (NavPath && NavPath->IsValid())
{
if (CheckIfReachedNextLocation(Pawn, NavPath->PathPoints[IndexPath])) {
if (IndexPath + 1 >= NavPath->PathPoints.Num()) {
Output = ECountSecondsOutputPins::OnSuccess;
Pawn->Forward = 0;
Response.FinishAndTriggerIf(true, LatentActionInfo.ExecutionFunction, LatentActionInfo.Linkage, LatentActionInfo.CallbackTarget);
return;
}
IndexPath += 1;
}
FVector CurrentGoal = NavPath->PathPoints[IndexPath];
if (NextGoal != CurrentGoal) {
NextGoal = CurrentGoal;
}
SetNewRotationGoal(Pawn, CurrentGoal, RotationToFace);
SetActorRotation(Pawn, RotationToFace, World->GetDeltaSeconds());
DrawDebugPathLines(NavPath, World);
}
else
{
bAbort = true;
UE_LOG(LogTemp, Error, TEXT("Failed to find path."));
}
}```
If you need more information please let me know!!