Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MyAIController.h"
- #include "BehaviorTree/BehaviorTree.h"
- #include "Perception/PawnSensingComponent.h"
- // Sets default values
- AAICharacter::AAICharacter()
- {
- // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
- PrimaryActorTick.bCanEverTick = true;
- //Initializing the pawn sensing component
- PawnSensingComp = CreateDefaultSubobject<UPawnSensingComponent>(TEXT("PawnSensingComp"));
- //Set the peripheral vision angle to 90 degrees
- PawnSensingComp->SetPeripheralVisionAngle(90.f);
- }
- // Called when the game starts or when spawned
- void AAICharacter::BeginPlay()
- {
- Super::BeginPlay();
- //Register the function that is going to fire when the character sees a Pawn
- if (PawnSensingComp)
- {
- PawnSensingComp->OnSeePawn.AddDynamic(this, &AAICharacter::OnSeePlayer);
- }
- }
- void AAICharacter::OnSeePlayer(APawn* Pawn)
- {
- AMyAIController* AIController = Cast<AMyAIController>(GetController());
- //Set the seen target on the blackboard
- if (AIController)
- {
- GLog->Log("Oh hello there");
- AIController->SetSeenTarget(Pawn);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement