Getting Input Key Time Down in C++

Hello,

try the function GetPlayerController: As world context object you can use anything that implements GetWorld(), for instance ACharacter::GetWorld(), and as index use 0. Note that this function returns NULL during actor construction so if you are calling it in a tick make sure to check for NULL. You did not specify whether this is a multiplayer game or not. If it is, be advised that obtaining the player controller like this will only work on clients and non-dedicated servers. If the code you are writing might potentially run on both client and server, call IsLocalPlayer() on the player controller.

With that answered, I’d just like to note that every player-controlled pawn always has a player controller. For me it does not really come through as to what is the player controlled pawn; however, on whichever pawn that is you can just call GetController() on the pawn and cast it to a player controller safely. Casting your pawn to a player controller as you suggested won’t work because the classes are unrelated.

Cheers,
Univise