RemoveAll from TArray with GameplayTag

PirikitoBunito
Tue, 07 Mar 2023 18:20:49 +0000
C++

Hi,

I’m trying to filter out actors from my TArray based on their GameplayTag.
Actors don’t implement the GameplayTag interface on their own so I’m casting them to my BaseGameplayTagActor which just adds this feature to an Actor. My classes derive from this to be able to use GameplayTags.

Right now my setup is the following:

GetOverlappingActors(*outOverlappingActors);

if (outOverlappingActors->Num() < 0)
	return false;

// Predicate creation to allow TArray.RemoveAll
struct IsNotBrickable
{
	bool operator()(AActor *RemovalCandidate) const
	{
		ABaseGameplayTagActor *TagActor = dynamic_cast<ABaseGameplayTagActor *>(RemovalCandidate);

		return TagActor->HasMatchingGameplayTag(itemTag);
	}
};
outOverlappingActors->RemoveAll(IsNotBrickable());

How can I send the desired item tag to the struct?
Everything i’ve tried didn’t work.

5 posts - 2 participants