命中反应能力(HitReactions)
{{ currentPage ? currentPage.title : "" }}
命中反应能力:UGameplayAbility_HitReaction
用途:用于播放角色被命中后的命中蒙太奇与击倒蒙太奇
能力需要设置触发标签(AbilityTriggers)
需要设置NetExecutionPolicy为ServerInitiated(仅服务器启动)
NetSecurityPolicy设置为ServerOnly,不允许客户端激活与取消
变量/函数 | 描述 |
---|---|
HitFrontMontage HitBackMontage HitLeftMontage HitRightMontage | 命中 前后左右 四向蒙太奇 |
bCrouchHit HitCrouchFrontMontage HitCrouchBackMontage HitCrouchLeftMontage HitCrouchRightMontage | 是否有蹲伏命中蒙太奇 蹲伏命中前后左右 四向蒙太奇 |
KnockDownFrontMontage KnockDownBackMontage KnockDownLeftMontage KnockDownRightMontage | 击倒 前后左右蒙太奇 |
bKnockDownDetail KnockDownFrontLeftMontage KnockDownFrontRightMontage KnockDownBackLeftMontage KnockDownBackRightMontage | 是否为详细击倒(6向) 击倒 左前、右前、左后、右后 蒙太奇 |
ApplyHitEventData(FGameplayEventData* TriggerEventData, FDamageExtraData DamageData) | 应用命中事件数据 |
触发仅可通过服务器添加标签触发,需要传递相应的蒙太奇到TriggerEventData->OptionalObject中,需要由服务器进行选择
代码:
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);
}
}
{{{ content }}}