Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
set activation owned tag in c++ class instead of in blueprint and add…
Browse files Browse the repository at this point in the history
…ed check for whether or not the character is in the air before activating sprint ability
  • Loading branch information
chris-gong committed Oct 7, 2020
1 parent a4565d3 commit 68de944
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Binary file modified Content/GameplayAbilities/GA_Sprint.uasset
Binary file not shown.
23 changes: 10 additions & 13 deletions Source/Flopnite/Private/GameplayAbilities/SprintAbility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

USprintAbility::USprintAbility() {
InstancingPolicy = EGameplayAbilityInstancingPolicy::InstancedPerActor;
AbilityTags.AddTag(FGameplayTag::RequestGameplayTag(FName("Ability.Sprint")));
FGameplayTag SprintAbilityTag = FGameplayTag::RequestGameplayTag(FName("Ability.Sprint"));
AbilityTags.AddTag(SprintAbilityTag);
ActivationOwnedTags.AddTag(SprintAbilityTag);
AbilityInputID = EFNAbilityInputID::Sprint;
}

Expand Down Expand Up @@ -36,7 +38,7 @@ void USprintAbility::ActivateAbility(const FGameplayAbilitySpecHandle Handle, co
SprintEffectHandle = ApplyGameplayEffectToOwner(Handle, ActorInfo, ActivationInfo, NewObject<UGameplayEffect>(this, SprintEffect), 1);
// set a sprinting flag in character movement component to true
CharacterMovementComponent->RequestToStartSprinting = true;
UE_LOG(LogTemp, Warning, TEXT("sprint ability successfully activated"));
//UE_LOG(LogTemp, Warning, TEXT("sprint ability successfully activated"));

return;
}
Expand All @@ -52,18 +54,13 @@ bool USprintAbility::CanActivateAbility(const FGameplayAbilitySpecHandle Handle,
{
ACharacter* Character = CastChecked<ACharacter>(ActorInfo->AvatarActor.Get());
if (Character) {
// TODO: check if player is on the ground or not, or if they're aiming down sight, and etc.
return true;
}
else {
UE_LOG(LogTemp, Warning, TEXT("Cannot activate ability 1"));
return false;
UFNCharacterMovementComponent* CharacterMovementComponent = CastChecked<UFNCharacterMovementComponent>(Character->GetMovementComponent());
if (CharacterMovementComponent && !CharacterMovementComponent->IsFalling()) {
return true;
}
}
}
else {
UE_LOG(LogTemp, Warning, TEXT("Cannot activate ability 2"));
return false;
}
return false;
}

void USprintAbility::InputReleased(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo) {
Expand All @@ -89,7 +86,7 @@ void USprintAbility::CancelAbility(const FGameplayAbilitySpecHandle Handle, cons
}
// set a sprinting flag in character movement component to true
CharacterMovementComponent->RequestToStartSprinting = false;
UE_LOG(LogTemp, Warning, TEXT("sprint ability successfully cancelled"));
//UE_LOG(LogTemp, Warning, TEXT("sprint ability successfully cancelled"));

}
}
Expand Down

0 comments on commit 68de944

Please sign in to comment.