如何設置才能判定按鍵是否按住

[复制链接]
查看1745 | 回复2 | 2018-6-12 11:21:27 | 显示全部楼层 |阅读模式
小弟的目標是打算做到按下shift鍵,移動就變成跑步
但目前卡在一個地方,就是不能判定shift鍵按住放開

小弟的碼是這樣的

void AARPGCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
    Super::SetupPlayerInputComponent(InputComponent);
    InputComponent->BindAction("Run", IE_Pressed, this, &AARPGCharacter::StartRunning);
    InputComponent->BindAction("RunToggle", IE_Pressed, this, &AARPGCharacter::RunningToggle);
    InputComponent->BindAction("Run", IE_Pressed, this, &AARPGCharacter::StopRunning);
}


void AARPGCharacter::StartRunning()
{
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("開始跑步runing"));
}


void AARPGCharacter::StopRunning()
{   
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("停止跑步 StopRunning"));
}


但變成我按shift鍵就同時跑出
開始跑步
停止跑步
想問一下如何設定按下Shift鍵,就先出現「開始跑步」
放開Shift鍵,就先出現「停止跑步」


Xi_mo | 2018-6-12 15:07:17 | 显示全部楼层
松开是IE_Released
回复 支持 反对

使用道具 举报

cow1330 | 2018-6-13 10:02:22 | 显示全部楼层
感謝說明
一改就成功了,就下來小弟就知道作麼做了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

36

主题

77

回帖

256

积分

初阶编码师

积分
256