Skip to content

Commit

Permalink
Fix AI is not focusing on pawn mesh eye viewpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dyanikoglu committed May 11, 2021
1 parent 7dec82e commit 15e4ebb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Source/ALSV4_CPP/Private/AI/ALSAIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "AI/ALSAIController.h"

#include "Character/ALSBaseCharacter.h"

AALSAIController::AALSAIController()
{
}
Expand All @@ -20,3 +22,18 @@ void AALSAIController::OnPossess(APawn* InPawn)
RunBehaviorTree(Behaviour);
}
}

FVector AALSAIController::GetFocalPointOnActor(const AActor* Actor) const
{
if (Actor == nullptr)
{
return FAISystem::InvalidLocation;
}
const APawn* FocusPawn = Cast<APawn>(Actor);
if (FocusPawn)
{
// Focus on pawn's eye view point
return FocusPawn->GetPawnViewLocation();
}
return Actor->GetActorLocation();
}
1 change: 0 additions & 1 deletion Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "Library/ALSMathLibrary.h"
#include "Components/CapsuleComponent.h"
#include "Components/TimelineComponent.h"
#include "Curves/CurveVector.h"
#include "Curves/CurveFloat.h"
#include "Character/ALSCharacterMovementComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
Expand Down
2 changes: 2 additions & 0 deletions Source/ALSV4_CPP/Public/AI/ALSAIController.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ class ALSV4_CPP_API AALSAIController : public AAIController

protected:
virtual void OnPossess(APawn* InPawn) override;

virtual FVector GetFocalPointOnActor(const AActor *Actor) const override;
};

0 comments on commit 15e4ebb

Please sign in to comment.