AI Bahavior Tree was Inactive and AIBehavior has null pointer

Code:

CPP

#include "ShooterAIController.h"

#include "Kismet/GameplayStatics.h"

#include "BehaviorTree/BlackboardComponent.h"

// Called when the game starts or when spawned

void AShooterAIController::BeginPlay()

{

    Super::BeginPlay();

    //PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(),0);

    // SetFocus(PlayerPawn);

    //MoveToActor(PlayerPawn, AcceptanceRadius);

    if (AIBehavior != nullptr)

    {

        RunBehaviorTree(AIBehavior);

        APawn *PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);

        GetBlackboardComponent()->SetValueAsVector(TEXT("PlayerLocation"), PlayerPawn->GetActorLocation());

    }else{

        UE_LOG(LogTemp, Warning, TEXT("NOT FOUND AI TREE"));

    }

    

}

// Called every frame

void AShooterAIController::Tick(float DeltaTime)

{

    Super::Tick(DeltaTime);

    

    // if (LineOfSightTo(PlayerPawn))

    // {   

    //     SetFocus(PlayerPawn);

    //     MoveToActor(PlayerPawn, AcceptanceRadius);

    // }

    // else

    // {

    //     ClearFocus(EAIFocusPriority::Gameplay);

    //     StopMovement();

    // }

        

}

Header file:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"

#include "AIController.h"

#include "ShooterAIController.generated.h"

/**

 * 

 */

UCLASS()

class SIMPLESHOOTER_API AShooterAIController : public AAIController

{

    GENERATED_BODY()

protected:

    // Called when the game starts or when spawned

    virtual void BeginPlay() override;

    // Called every frame

    virtual void Tick(float DeltaTime) override;

private:

    UPROPERTY(EditAnywhere)

    class UBehaviorTree* AIBehavior; 

};

Capture1


Where is it null?

Privacy & Terms