I ran into a problem when implementing stealth assassinations using the AbilitySystem. In the Stealth Kill ability, which is triggered by the killer, there is the following code, which, as I understand it, should trigger a GameplayEvent, in which an ability with a certain tag is activated.
if (UAbilitySystemComponent* TargetASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(TargetActor))
{
FGameplayTag EventTag = FUmbraGameplayTags::Get().Ability_Stealth_Victim;
UE_LOG(LogTemp, Warning, TEXT("Stealth kill event tag: %s"), *EventTag.ToString());
//UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(TargetActor, EventTag, EventData);
int n = TargetASC->HandleGameplayEvent(EventTag, &EventData);
UE_LOG(LogTemp, Warning, TEXT("Stealth kill event sent to target actor | Abilities activated: %d"), n);
}
else
{
UE_LOG(LogTemp, Error, TEXT("Target actor doesn't have ability system component"));
}
My problem is that when passing the EventTag to the HandleGameplayEvent, it becomes invalid.
int32 UAbilitySystemComponent::HandleGameplayEvent(FGameplayTag EventTag, const FGameplayEventData* Payload)
{
int32 TriggeredCount = 0;
FGameplayTag CurrentTag = EventTag;
ABILITYLIST_SCOPE_LOCK();
while (CurrentTag.IsValid())
....
}
In debug mode, the value of the EventTag in the function itself becomes something like this
{TagName=Illegal name (block index out of range)}
Accordingly, the while loop does not enter and the victim’s ability is not activated.
I’ve tried various ways to pass the tag. I used a separate variable, I used EventData.EventTag. I also tried to add a non-native tag, but to do it in the project settings. And yet, the result remains the same.
I don’t have much experience in Unreal Engine and I don’t understand at all what the problem might be here.
I will be glad to help!