If Press AnyKey
Unreal
void APlayerChar::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
APlayerController* plyrCntrlr = GetWorld()->GetFirstPlayerController();
if(plyrCntrlr->WasInputKeyJustPressed(EKeys::AnyKey))
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Cyan, TEXT("Key pressed"));//need #include "Engine/GameEngine.h"
}
Unity
bool pressKey;
void Update() => pressKey = Input.anyKey | Input.GetKey(KeyCode.E);
void OnGUI()
{
if(pressKey)
GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
}
Comments
Post a Comment