原文:https://answers.unrealengine.com/questions/160688/access-player-location-from-another-actor.html
?
FVector PlayerLocation = GetWorld()->GetFirstPlayerController()->GetActorLocation();
?
这些写会编译错误:
error C2248: 'AController::GetActorLocation' : cannot access private member declared in class 'AController'
?
?
正确写法:
You trying to get location of player controller which does not have location, you should get pawn possessed by that controller first which should be player pawn/character (ACharacter is extended version of APawn and APawn is most basic form of character in the game)
- FVectorPlayerLocation=GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();