Access Player from c++

Because this is a top google search result, note that the above code for using GetPlayerControllerIterator does not seem to work as of 4.22. I have to use the following to get a playerController reference.



for (FConstPlayerControllerIterator iter = GetWorld()->GetPlayerControllerIterator(); iter; ++iter) {
    APlayerController *playerController = iter->Get();
    //...
}


4 Likes