Finding a specific Pawn, which method is better or faster?

Hey,
im pretty new to UE4 and trying to find out a few things which i already knew in for example the Unity engine.

I found out, that there a several ways to find a pawn (or maybe the only pawn in a simple project) and would like to know, which of these methods is better or the performance difference can be ignored.

The first one i tried was this:

for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; ++It)
	{
		APawn* tmpPawn = *It;
		if (tmpPawn->ActorHasTag(TEXT("Player")))
		{
			UE_LOG(GameModeLog, Warning, TEXT("Player found! YEAH!"));
			pawn = Cast<ARollABall_UnrealBall> (tmpPawn->GetClass());
		}
	}

pawn->TestLog();

Iterating through all pawn objects as i understand it, checking the tags and then calling the function of that specific pawn.

The second approach:

ARollABall_UnrealBall* tmp = Cast<ARollABall_UnrealBall> (GetWorld()->GetFirstPlayerController()->GetPawn());
tmp->TestLog();

Here i just use the GetWorld() function to access the controller and get the pawn with casting etc.

If there is a better method to do this, i would appreciate it if you could tell me the right way :slight_smile: