As a side note, your code may crash in line 11 if you click on BSP. It would happen, because if you’d click on BSP Hit.bBlockingHit would return true, but a BSP is not an actor thus Hit.GetActor() would be null.
To prevent such cases, you should alter your 9th line to smth like this:
if (Hit.bBlockingHit && Hit.GetActor())
or totally ignore Hit.bBlockingHit part and go for
if (Hit.GetActor())
Also, i’d remove line 11 as it isn’t needed that much IMO. So the code would look like:
void AMyPlayerController::MousePressed()
{
UE_LOG(LogTemp, Warning, TEXT("Mouse Pressed"));
// Trace to see what is under the mouse cursor
FHitResult Hit;
GetHitResultUnderCursor(ECC_Visibility, false, Hit);
if (Hit.GetActor())
{
AMyPaperFlipbookActor* OtherCharacter = Cast<AMyPaperFlipbookActor>(Hit.GetActor());
if(OtherCharacter)
{
OtherCharacter->Selected();
}
}
bMoveToMouseCursor = false;
}