I have seen a lot of ways to use the node based visual scripts to stop player input; However, I have not seen a single example of how to disable the player input in visual studio?
You can disable player input using the function:
This should be called on the actor you wish to disable input for. You need to have a pointer to the current player controller, and pass this as the function's argument. You can easily get the first (and usually only, in single player game) player controller from the current world:
Quick example, with
PlayerPawn being a pointer to the AActor that you wish to disable input for:
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); PlayerPawn->DisableInput(PlayerController);
It's been quite some time since I've used UE4 in a moderate-sized project, but what I would do first is:
UInputComponent* Temporary = PlayerInputComponent;
PlayerInputComponent = nullptr;to block input
Later restore input by
PlayerInputComponent = Temporary;
You might be able to use C++ standard move semantics with UE4, though I wouldn't guarantee it because usually UE4 does things in it's own weird but necessary way. What I posted above would be the first thing I'd do, so no guarantees if it works. Would be great if someone could confirm or deny.
ALSO: Please note that Visual Studio is not the only way to access/modify C++ code in UE4 environment. You can basically use any text editor to do so.