I am currently working on a combat system and I wanted to be able to have key combos to execute combat moves and such, and I am detecting key input type as well for example, if the key is tapped, or long pressed.
I use this line below to record the time a key is pressed, and time when the same key is released, so I can differentiate whether the key is just a quick tapped or long pressed.
FPlatformTime::Seconds();
and when the the game detected a key press, it will execute the function below, using a timer and stopped on released.
//Long Press
void ABasePlayerController::StartRepeat(UFunction* FunctionNamesToCall, FKey KeyInput)
{
//Execute if Timer is still active
if (IsKeyDown != false && GetWorld()->GetTimerManager().IsTimerActive(RepeatTimerHandle) && WasInputKeyJustPressed(KeyInput))
{
CalledFunction.Broadcast(FunctionNamesToCall, KeyInput);
}
}
The problem is when I wanted to make a key combination, and I stopped this function, whenever a new Key is pressed, the new key will be considered as a Long Pressed as well. My current codes only able to register input types after the key is released, and I wanted to be able to make a charging combo as well.
For example when I'm holding a Tab and I tap a new different key, both keys will be considered as a Long Pressed, while the expected result supposed to be Long Pressed Tab key, and the new pressed key is a simple quick tap.
Any ideas? Thanks!