hi,
thanks for the quick reply.
no I just want exactly the same behaviour I already have in my bp logic, with the same error tolerance.
but this is somehow not working
hi,
thanks for the quick reply.
no I just want exactly the same behaviour I already have in my bp logic, with the same error tolerance.
but this is somehow not working
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
You want it to be closer than 150? Then try the following:
nearEnough = (aiPawnVector.DistSquared()) < (maxTolerance * maxTolerance);
Your code looks correct. Debug output the vectors and try to get all components closer than maxTolerance to each other.
you have an static function on c++ FVector::Equals(your vector, tolerance).
So would be something like :
MyLocation.Equals(EnemyLocation, 1.0f) → this gonna return a true or false result.