HitReaction:UGameplayAbility_HitReaction
Purpose: Used to play hit montages and knock down montages after a character is hit
Ability requires setting trigger tags (AbilityTriggers)
NetExecutionPolicy Set to ServerInitiated
NetSecurityPolicy Set to ServerOnly,Do not allow client activation and cancellation
Variable/Function | Explain |
---|---|
HitFrontMontage HitBackMontage HitLeftMontage HitRightMontage | |
bCrouchHit HitCrouchFrontMontage HitCrouchBackMontage HitCrouchLeftMontage HitCrouchRightMontage | Is there a crouching hit montage |
KnockDownFrontMontage KnockDownBackMontage KnockDownLeftMontage KnockDownRightMontage | KnockDown |
bKnockDownDetail KnockDownFrontLeftMontage KnockDownFrontRightMontage KnockDownBackLeftMontage KnockDownBackRightMontage | Is it a detailed knockdown (6-way) |
ApplyHitEventData(FGameplayEventData* TriggerEventData, FDamageExtraData DamageData) | ApplyHitEventData |
Triggering can only be triggered by adding tags to the server, and the corresponding montage needs to be passed to TriggerEventData ->OptionalObject, which needs to be selected by the server
Source:
void APrimalCharacter::ApplyHitReaction(float BaseDamage, AController* EventInstigator, AActor* DamageCauser, TSubclassOf<UPrimalDamageType> DamageTypeClass, FDamageExtraData DamageData){
TSubclassOf<UGameplayAbility_HitReaction> HitReactionClass = HitReactionAbilityClass;
if (IsValid(CurrentWeapon)) {
if (CurrentWeapon->HitReactionAbilityClass)
HitReactionClass = CurrentWeapon->HitReactionAbilityClass;
}
if (HitReactionClass) {
FGameplayEventData EventData = FGameplayEventData();
EventData.EventTag = HitReactionTriggerTag;
EventData.Target = this;
AbilitySystemComponent->GetOwnedGameplayTags(EventData.TargetTags);
if (DamageCauser) {
UUltimateAbilitySystemComponent* InstigatorASC = Cast<UUltimateAbilitySystemComponent>(DamageCauser->GetComponentByClass(UUltimateAbilitySystemComponent::StaticClass()));
InstigatorASC->GetOwnedGameplayTags(EventData.InstigatorTags);
EventData.Instigator = DamageCauser;
}
if (HitReactionClass->GetDefaultObject<UGameplayAbility_HitReaction>()->ApplyHitEventData(&EventData, DamageData))
AbilitySystemComponent->HandleGameplayEvent(HitReactionTriggerTag, &EventData);
}
}