Append
Some of code:
InputComponent->BindAction("BurstQ", IE_Pressed, this,&AMyPawn::StartBurst);
InputComponent->BindAction("BurstQ", IE_Repeat, this,&AMyPawn::GoBurst);
InputComponent->BindAction("BurstQ", IE_Released, this,&AMyPawn::StopBurst);
void AMyPawn::StartBurst(){
//Get pressed time
PressedTime = FDateTime::Now().GetTicks();
}
void AMyPawn::GoBurst(){
//reset pressed time to 0 as every time Q key released
if (PressedTime == 0) {
return;
}
int64 HoldingTime = PressedTime / 10000;
//set BurstThreshold to 3 secs
if (HoldingTime >= BurstThreshold) {
bBurst = true; //go burst.
}
}
void AMyPawn::StopBurst(){
bBurst = false; //stop Burst
PressedTime = 0;
}