Hi,
I’ve tried to move my AI controller from blueprint to code, and it compiles nicely, but when I try to either play in editor or even navigate to my pawn’s blueprint’s directory to try and change its’ AI controller, editor crashes. I must’ve made some error in AI controller class, but can’t really see it.
TankAICon.h
#pragma once
#include "Runtime/AIModule/Classes/BehaviorTree/BlackboardComponent.h"
#include "AIController.h"
#include "TankAICon.generated.h"
UCLASS()
class TANKTICS_API ATankAICon : public AAIController
{
GENERATED_BODY()
virtual void Possess(class APawn* InPawn) override;
public:
UFUNCTION(BlueprintCallable, Category = "Movement")
void NavigateToPoint(FVector PointLoc);
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Config")
UBlackboardComponent* BlackboardComp;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Config")
UBehaviorTreeComponent* BehaviorComp;
TankAICon.cpp
#include "Tanktics.h"
#include "TankAICon.h"
#include "Tank.h"
void ATankAICon::Possess(APawn* InPawn)
{
Super::Possess(InPawn);
ATank* ControlledTank = Cast<ATank>(InPawn);
if (ControlledTank)
{
if (ControlledTank->BehaviorComp->BlackboardAsset)
BlackboardComp->InitializeBlackboard(*ControlledTank->BehaviorComp->BlackboardAsset);
BehaviorComp->StartTree(*ControlledTank->BehaviorComp);
}
}
void ATankAICon::NavigateToPoint(FVector PointLoc)
{
float PathLength;
GetWorld()->GetNavigationSystem()->GetPathLength(GetPawn()->GetActorLocation(), PointLoc, PathLength);
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, "Path length: " + FString::SanitizeFloat(PathLength));
}
Also, I’ve uploaded log file here, if it happens to be needed.
I hope someone notices my error, thanks in advance