Hi, I want my character to move faster when the player taps a button and the faster the player taps the faster the character moves. How would I achieve this? I have set up the buttons to work when tapped and not when its held by using a timer.
The code I have so far is:
void ABaseCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
AddMovementInput(GetActorForwardVector() * axis);
}
void ABaseCharacter::StartMovement() // Called on Button Start
{
FTimerDelegate TouchTimerDelegate;
TouchTimerDelegate.BindUObject(this, &ABaseCharacter::EndMovement);
TapCount++;
if (TapCount == 1)
{
axis = 1.0f;
}
GetWorld()->GetTimerManager().SetTimer(TouchTimerHandle, TouchTimerDelegate, 0.1f, false);
}
void ABaseCharacter::EndMovement() // Called on button released or on timer end
{
TapCount = 0;
GetWorld()->GetTimerManager().ClearTimer(TouchTimerHandle);
axis = 0.0f;
}