Gameplay Tasks - WaitInputRelease
How it Works
WaitInputRelease waits for the button/key that was pressed to activate the ability to be released. When the button/key is released, it calls the OnRelease dynamic multicast delegate and sends one float parameter. This parameter is the number of seconds the key was held.
The time held differs slightly from owning client to server, but is fairly close and does not seem to increase with lag.
What can I use it for?
This can be used for things like charging up an attack based on how long the activation button/key was held.
Code Samples
UMyChargeUpGameplayAbility::OnChargeUpComplete will be called when the input key is released.
void UMyChargeUpGameplayAbility::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) { UAbilityTask_WaitInputRelease* Task_WaitInputReleaseForChargeTime = UAbilityTask_WaitInputRelease::WaitInputRelease(this, false); Task_WaitInputReleaseForChargeTime->OnRelease.AddDynamic(this, &UMyChargeUpGameplayAbility::OnChargeUpComplete); Task_WaitInputReleaseForChargeTime->ReadyForActivation(); } void UMyChargeUpGameplayAbility::OnChargeUpComplete(float AmountOfTimeHeld) { }