Say I have a door. I want to know if the player is in front of or behind it. To do this I thought I’d get the vector going from the door to the player, compare it to the forward vector of the door, and see if the angle between them falls between 0 and 180 (assuming the range is 0 - 360).
FVector doorToPlayer = player->GetActorLocation() - door->GetComponentLocation();
float angle = FVector::DotProduct(door->GetForwardVector(), doorToPlayer);
angle = FMath::RadiansToDegrees(acosf(angle));
However, the angle is always NAN as soon as I pass it through ascof
.
How can I check this properly? I also don’t really know the range returned.