Hello. So i am able to use on see pawn in blueprint and print string to check if its firing and it is, but i use UE_LOG in c++ in OnSeePawn method and its not firing. Here is the code.
Header
UPROPERTY(VisibleAnywhere)
UPawnSensingComponent* PawnSensingComp;
UFUNCTION()
void OnSeePawn(APawn* Pawn);
CPP
Constructor:
PawnSensingComp = CreateDefaultSubobject(TEXT(“PawnSensingComp”));
PawnSensingComp->OnSeePawn.AddDynamic(this, &AFPSAIGuard::OnSeePawn);
void AFPSAIGuard::OnSeePawn(APawn* Pawn)
{
UE_LOG(LogTemp, Warning, TEXT(“PawnSeen”))
}
Please help!
I cant use TSubjectPtr because its deprecated. I was just following a tutorial because i wanted to do perception in c++ not blueprint. So i feel like the tutorial might be outdated. So i just wanna ask. Is this the best approach to this? Like create a class based on character and use it for AI or is there a better and more efficient way to do it(in c++) in unreal engine 4.21.
Hello! Do you find solution? I have the same problem and can not find how to fix it via all internet.
I have got it.
You have to writre binding code (PawnSensingComp->OnSeePawn.AddDynamic(this, &AFPSAIGuard::OnSeePawn)
not in the Constructor, but in BeginPlay function.
That work fine to me.
1 Like