当前位置: 代码迷 >> Ruby/Rails >> [UE4] error C2248: 'AController:GetActorLocation' : cannot access private
  详细解决方案

[UE4] error C2248: 'AController:GetActorLocation' : cannot access private

热度:517   发布时间:2016-04-29 02:07:31.0
[UE4] error C2248: 'AController::GetActorLocation' : cannot access private

原文: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)

  1. FVectorPlayerLocation=GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();
  相关解决方案