Hi,
I’m currently transforming most of my bp to c++.
I got stuck on some point and I cannot find out what I’m doing different then in the blueprint.
I want to know when my player character is close to the enemy which is possessed by the AIController.
But when I’m transforming the bp to c++ the condition always fails, but in BP it is working, so I think I missed something here
Here is my c++ code
float maxTolerance = 130.0f
bool nearEnough = false;
APlayerController* playerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
FVector aiPawnVector = aiController->GetControlledPawn()->GetActorLocation();
FVector enemyVector = playerController->GetControlledPawn()->GetActorLocation();
nearEnough = aiPawnVector.Equals(enemyVector, maxTolerance);
Here is the BP logic which works fine
Thanks for pointing me in the correct direction ![]()
EDIT
First post was confusing because I had different float tolerance accidently. this was a typo.
I just want to convert exactly the same from bp to c++
Best
