`
aigo
  • 浏览: 2537214 次
  • 性别: Icon_minigender_1
  • 来自: 宜昌
社区版块
存档分类
最新评论

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

UE4 
阅读更多

原文: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();
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics