Wiping Gameplay tags on death

RareAlexC
Thu, 21 Aug 2025 15:17:37 +0000
Programming & Scripting

What is intended approach to wipe all tags from a character?

As well as adding loose gameplay tags, we add minimal replicated tags ( AbilitySystem->AddMinimalReplicationGameplayTags( GameplayTags ) ) in places where we want them to be predicted.

For the most part these tags are managed on an individual basis, but there are some states the player can get into where a tag is not correctly removed when they die. Instead of requiring individual watertight logic to clean all of these up on death, it makes sense that there would be a way to wipe all tags and start fresh (to minimize any room for human error / need for boilerplate logic).

Simply wiping all loose tags, leaves the minimal replicated ones, causing them to be re-added for remote players. Access to the list of these minimal replicated tags is protected, so the solution I’ve come up with is the following in a child of the ability system component:

void UExtendedAbilitySystemComponent::RemoveAllGameplayTagsAndEffects()
{
	// Remove all active effects (removes effect-granted tags)
	RemoveActiveEffects( FGameplayEffectQuery() );

	// Remove all loose tags
	UpdateTagMap( GetOwnedGameplayTags() , 0 );

	const bool HasLocalNetOwner = GetOwner()->HasLocalNetOwner();

	if ( HasLocalNetOwner || GetOwner()->HasAuthority() )
	{
		// Clear replicated owned tags
		GetMinimalReplicationTags_Mutable().RemoveAllTags();
	}
}

Is this a valid approach? What is the intended method of cleaning up minimal replicated tags? Is it expected that tags will always be added and cleaned up on an individual basis, and there should never be a need to wipe them all?