Download

SimpleMoveToLocation Suddenly not working

I would expect nothing less from this function…

Not entirely sure when this stopped working, however, a previous commit I have works just fine with hardly any notable changes to the related code. The problem is not multiplayer/ replication related as it does not work when playing offline either.

LOG:


LogTemp: Warning: MoveTo called // I right click to move unit to my cursor
LogTemp: Warning: Hit Something at X: -3192.548340 Y: -175.103302 Z: 181.500000 // Nothing is wrong with the location, it is accurate
LogTemp: Warning: Attained unit controller BP_UnitAIController_C_7 // Seems to be getting the selected unit just fine
LogTemp: Warning: SimpleMoveToLocation called in Server MoveTo
LogTemp: Warning: MoveTo called // Notice how it never logs the result as if it's still attempting to move to the location
LogTemp: Warning: Hit Something at X: -3432.267090 Y: -858.689575 Z: 181.500000 // Right click again
LogTemp: Warning: Attained unit controller BP_UnitAIController_C_7
LogTemp: Warning: PathFollowingResult: Aborted[UserAbort NewRequest ForcedScript] // This time the result is logged but as you see it says it canceled the previous one which was seemingly ongoing
LogTemp: Warning: SimpleMoveToLocation called in Server MoveTo

MoveTo Function:


void ARtsPlayerController::Server_MoveTo_Implementation(FHitResult Hit, const TArray<ARTSPrototypeCharacter*>& Units)
{
     UE_LOG(LogTemp, Warning, TEXT("MoveTo called"));
     if (Hit.bBlockingHit)
     {
          UE_LOG(LogTemp, Warning, TEXT("Hit Something at X: %f Y: %f Z: %f"), Hit.ImpactPoint.X, Hit.ImpactPoint.Y, Hit.ImpactPoint.Z);

          // We hit something, cycle through selected units and move there
          for(ARTSPrototypeCharacter* Unit : Units)
          {
               AAIController* UnitController = Cast<AAIController>(Unit->GetController());
               if(UnitController != nullptr)
               {
                    FString UnitName = UnitController->GetDebugName(UnitController);
                    UE_LOG(LogTemp, Warning, TEXT("Attained unit controller %s"), *UnitName);

                    UAIBlueprintHelperLibrary::SimpleMoveToLocation(UnitController, Hit.ImpactPoint);
                    UE_LOG(LogTemp, Warning, TEXT("SimpleMoveToLocation called in Server MoveTo"));
               }
               else
               {
                    UE_LOG(LogTemp, Warning, TEXT("Failed to get unit controller"));
               }
              
          }
     }
}

Overridden OnMoveCompleted Function:


void AUnitAIController::OnMoveCompleted(FAIRequestID RequestID, const FPathFollowingResult & Result)
{
     Super::OnMoveCompleted(RequestID, Result);

     UE_LOG(LogTemp, Warning, TEXT("PathFollowingResult: %s"), *Result.ToString());
}

The only notable/ relevant changes made from this version to the previous one that works is that I now pass in the Units array and Hit, I pass Hit due to not being able to calculate line traces on a server function and pass the *Units *array for replication reasons. I tried reversing passing in the Units array which led to no change. After getting that *OnMoveCompleted *result log it doesn’t seem like that would be the problem though.

However, I made many changes to many other things (seemingly irrelevant things but who knows), some blueprint which I can’t view changes for (I’ve really got to start incessantly making commits), and I wonder if anyone knows of any silly little thing that may have caused this problem to occur or just know what would cause the *SimpleMoveTo *to get stuck and never return a result. Yes I have a movement component, yes the pawn controlled by the AI is a character, yes I have a nav mesh (like I said, it was working fine), I also made sure I don’t have physics enabled on my character as I’ve heard that can cause problems.

Let me know if you need additional info.

I thank you for your time, the length some people go to help random people like me with their problems is amazing and I don’t really understand it but I will try to pay forward by helping others!

Never figured it out, just reverted my commit and copied over the missing code and it works fine now. I swear the the SimpleMoveTo function is finnicky :rolleyes: smh.