Using either “Get Controller” or “Get Player Controller” return the same blueprint but promote to variable, Get Controller is an actor reference and Get Player Controller is a Player Controller reference. Thing is referencing the controller using Get Player Controller is only by index but I want to get it by it’s hierarchy ?
GetController is, as far as i know, an APawn Function. It tries to get the Controller that is ‘controlling’ the Pawn.
If you call this on the PlayerCharacter (inside its Blueprint), you are going to get the PlayerController which is controlling it.
But only if it is really possessed by the PlayerController. Calling this on a Pawn that is not controlled, will return a null pointer (empty reference).
GetController also works on Pawns like AI and it might return the AIController then (don’t quote me on that).
The Reference you will get will still just be an “AController”. This is the base class of PlayerController or AIController. You must cast it
down to the PlayerController then.
GetPlayerController on the other hand returns the PlayerController based on the Index. In Singleplayer, LAN and Online Mathes, you will most likely just use
the index 0. I guess it iterates through alle PlayerController actors and return the first one with that. Normally there is only one local PlayerController.
The index can be used once you play with more than 1 person on the same computer. Like a Super Smash Brothers Match, Mario Kart or something like that.
Controller Docs: Controller | Unreal Engine Documentation
Thanks, been helpful.