How fast is GetWorld()->OverlapMulti?

Hello all! I have created a service for my behavior tree:




/* This function finds the nearest usable actor. */
AABUsableActor* UABActorSensor::FindNearestUsableActor()
{
	const FVector ownerPosition = GetOwner()->GetActorLocation();

	AABUsableActor* nearestActor = nullptr;

	TArray<FOverlapResult> overlaps;
	if (GetWorld()->OverlapMulti(overlaps, ownerPosition, FQuat::Identity, ECC_Visibility, FCollisionShape::MakeSphere(400), FCollisionQueryParams(false)))
	{
		float smallestDistance = FVector::Dist(ownerPosition, overlaps[overlaps.Num() - 1].GetActor()->GetActorLocation());

		for (int32 i = 0; i < overlaps.Num(); ++i)
		{
			AActor* actor = overlaps*.GetActor();

			float dist = FVector::Dist(ownerPosition, actor->GetActorLocation());

			if (dist <= smallestDistance)
			{
				smallestDistance = dist;
				nearestActor = Cast<AABUsableActor>(actor);
			}
		}
	}

	if (nearestActor)
		GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Green, nearestActor->GetName());

	return nearestActor;
}



&d=1406151719

I haven’t commented this code out as you can see, but I will soon (usually comment my code after it is working correctly). But what it does is use GetWorld()->OverlapMulti to get the actors around the character, then gets the closest actor to the player (I need to work on it though lol). How fast is GetWorld()->OverlapMulti?