Prediction Sense Doesn't Work When Character Jumps

Normally, Prediction sense works quite well, but it stops working whenever the character jumps. The reason is probably that it detects the PredictedLocation at a point that’s quite far below and outside the NavMesh bounds. To solve this, I tried using the ProjectPointToNavigation function, and i even added an extra value to the Z-axis, hoping it might help, but it still didn’t work. How to solve this problem?

Here is the first code:

if (Stimulus.Type == SensePredictionID)
{
    if (Stimulus.WasSuccessfullySensed())
    {
        FVector PredictedLocation = Stimulus.StimulusLocation;

            DrawDebugSphere(GetWorld(), PredictedLocation, 30.f, 18.f, FColor::Red, false, 7.f, 0.f, 0.3f);

            BlackboardComp->SetValueAsVector(FName("PredictedLocation"), PredictedLocation);
        }
 
    }
    else
    {
        UE_LOG(LogTemp, Warning,TEXT("Prediction sense didn't work"))
    }
}

And here is the second code:

if (Stimulus.Type == SensePredictionID)
{
    if (Stimulus.WasSuccessfullySensed())
    {
        FVector PredictedLocation = Stimulus.StimulusLocation;

        //DrawDebugSphere(GetWorld(), PredictedLocation, 30.f, 18.f, FColor::Red, false, 7.f, 0.f, 0.3f);

        FNavLocation NavLocation;
        bool OnNavigationMesh = UNavigationSystemV1::GetCurrent(GetWorld())->ProjectPointToNavigation(PredictedLocation, NavLocation);
        

        if (OnNavigationMesh)
        {
            FVector Z(0.f, 0.f, 120.f);
            FVector RealPredictedLocation = NavLocation.Location + Z;

            
            DrawDebugSphere(GetWorld(), RealPredictedLocation, 30.f, 18.f, FColor::Red, false, 7.f, 0.f, 0.3f);

            BlackboardComp->SetValueAsVector(FName("PredictedLocation"), RealPredictedLocation);
        }

        
    }
    else
    {
        UE_LOG(LogTemp, Warning,TEXT("Prediction sense didn't work"))
    }
}

Hi. I couldn’t solve this problem in a general way, but I found a simple temporary solution that works. I thought I’d share it in case someone else runs into the same issue in the future.
The idea is simple: we just set the Z vector the PredictedLocation equal to the Z vector of our PlayerCharacter.

Code:

if (Stimulus.Type == SensePredictionID)
{
    if (Stimulus.WasSuccessfullySensed())
    {
        
        FVector PredictedLocation = Stimulus.StimulusLocation;
        FVector PlayerCharacterLoc;

        PlayerCharacterLoc = PlayerCharacter->GetActorLocation();

        PredictedLocation.Z = PlayerCharacterLoc.Z;

        DrawDebugSphere(GetWorld(), PredictedLocation, 30.f, 18.f, FColor::Red, false, 7.f, 0.f, 0.3f);
        BlackboardComp->SetValueAsVector(FName("PredictedLocation"), PredictedLocation);
    }
    else
    {
        UE_LOG(LogTemp, Warning,TEXT("Prediction sense didn't work"))
    }
}