From cc8c789542c777ec9da4f4c830fad5733dea2f39 Mon Sep 17 00:00:00 2001 From: BrendanLoBuglio Date: Tue, 15 Jan 2019 16:37:34 -0800 Subject: [PATCH] Changed BTTask_FlyTo to provide MovementComponents with normalized input vectors instead of raw deltas to the next waypoint, as this is consistent with how normal PathFollowingComponents give input to MovementComponents --- .../Private/BehaviorTree/BTTask_FlyTo.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/DonAINavigation/Private/BehaviorTree/BTTask_FlyTo.cpp b/Source/DonAINavigation/Private/BehaviorTree/BTTask_FlyTo.cpp index fd1e5a8..e8c0a17 100644 --- a/Source/DonAINavigation/Private/BehaviorTree/BTTask_FlyTo.cpp +++ b/Source/DonAINavigation/Private/BehaviorTree/BTTask_FlyTo.cpp @@ -309,7 +309,8 @@ void UBTTask_FlyTo::TickPathNavigation(UBehaviorTreeComponent& OwnerComp, FBT_Fl return; } - FVector flightDirection = queryResults.PathSolutionOptimized[MyMemory->solutionTraversalIndex] - pawn->GetActorLocation(); + FVector deltaToNextNode = queryResults.PathSolutionOptimized[MyMemory->solutionTraversalIndex] - pawn->GetActorLocation(); + FVector nextNodeDirection = deltaToNextNode.GetSafeNormal(); //auto navigator = Cast(pawn); @@ -317,18 +318,18 @@ void UBTTask_FlyTo::TickPathNavigation(UBehaviorTreeComponent& OwnerComp, FBT_Fl if (MyMemory->bIsANavigator) { // Customized movement handling for advanced users: - IDonNavigator::Execute_AddMovementInputCustom(pawn, flightDirection, 1.f); + IDonNavigator::Execute_AddMovementInputCustom(pawn, nextNodeDirection, 1.f); } else { // Default movement (handled by Pawn or Character class) - pawn->AddMovementInput(flightDirection, 1.f); + pawn->AddMovementInput(nextNodeDirection, 1.f); } //UE_LOG(DoNNavigationLog, Verbose, TEXT("Segment %d Distance: %f"), MyMemory->solutionTraversalIndex, flightDirection.Size()); // Reached next segment: - if (flightDirection.Size() <= MinimumProximityRequired) + if (deltaToNextNode.Size() <= MinimumProximityRequired) { // Goal reached? if (MyMemory->solutionTraversalIndex == queryResults.PathSolutionOptimized.Num() - 1)