UE get player controller

 

  1. UGameplayStatics::GetPlayerController(GetWorld(), 0);
  2.  

Then you don't need to iterate through all of them. For example if you are in a Singleplayer Game.

더 ▼

답변됨 Nov 13 '14 at 4:29 PM

avatar image

eXi
7.2k  340  195  482

18

Depends on what you want to do and where you want to do it.

The main way you'd do this is here.

  1. for( FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator )
  2. {
  3. }
  4.  

Some things have the owner variable as a APlayerController (`APlayerState`, etc)

Clients only have 1 controller, their own. Servers have ALL controllers. You'll want to use IsLocalPlayerController to differentiate on the server.

더 ▼

답변됨 Jul 02 '14 at 2:38 AM

avatar image

Crzyhomer STAFF
1.3k  35  26  104

avatar image dbrizov Jul 02 '14 at 2:47 AM

I see, thank you very much :)

avatar image Mungyun Nov 13 '14 at 4:05 PM
6

Out of curiousity, does GetWorld()->GetFirstPlayerController() do the same thing?

avatar image dbrizov Nov 13 '14 at 4:53 PM
1

Yes, it gets the player controller with index 0.

avatar image ColdSteel48 May 08 '17 at 7:27 AM Newest

Yes, but it takes less code (look at implementation). Also it doesn't check if the World is Null (because it's a Worlds method obviously (only for your consideration).

댓글

이 블로그의 인기 게시물

About AActor!!! "UObject" has no member "BeginPlay"

UNREAL Android build information

Shader informations nice blog ~ ~