I have a problem with AI

Hello everyone. I just finished studying the simple shooter chapter and I have a problem. The fact is that the AI ​​does not react to me in any way, I did exactly like in the video tutorials.Pls help me







why?


This screenshot shows Player is “None”, where do you set that?

Could you tell me where to install it? apparently I missed it

It should be in BTService_PlayerLocationIfSeen.cpp
It was done towards the end of the lecture “BTServices In C++”

My code and code in rep

And you’ve set the blackboard key for that service?

yes

Could you try adding logs to each branch to see what’s getting executed?

I can, but tell me how to do it because I’m already completely confused

I’m saying to add UE_LOG statements at all points in that function.

void UBTService_PlayerLocationIfSeen::TickNode(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory, float DeltaSeconds) 
{
    Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);

    UE_LOG(LogTemp, Warning, TEXT("PlayerLocationIfSeen service is running"))

    APawn *PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
    if (PlayerPawn == nullptr)
    {
        UE_LOG(LogTemp, Warning, TEXT("Player == nullptr"))
        return;
    }

    if (OwnerComp.GetAIOwner() == nullptr)
    {
        UE_LOG(LogTemp, Warning, TEXT("OwnerComp.GetAIOwner() == nullptr"))
        return;
    }

    if (OwnerComp.GetAIOwner()->LineOfSightTo(PlayerPawn))
    {
        UE_LOG(LogTemp, Warning, TEXT("See player"))
        OwnerComp.GetBlackboardComponent()->SetValueAsObject(GetSelectedBlackboardKey(), PlayerPawn);
    }
    else
    {
        UE_LOG(LogTemp, Warning, TEXT("Don't see player"))
        OwnerComp.GetBlackboardComponent()->ClearValue(GetSelectedBlackboardKey());
    }
}

I don’t know why but it helped :smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms