conditions bug - Gameplay Camera System

Hello!
I bumped on the same issue and I found a bug on “Gameplay Tag” transition condition node code: indeed, the node evaluates your prev and next conditions but it will succeed in any case even with negative outcomes.

bool UGameplayTagTransitionCondition::OnTransitionMatches(const FCameraRigTransitionConditionMatchParams& Params) const
{
	bool bPreviousMatches = true; // <- by default the condition is true

	if (!PreviousGameplayTagQuery.IsEmpty())
	{
		if (Params.FromCameraRig)
		{
			FGameplayTagContainer TagContainer;
			Params.FromCameraRig->GetOwnedGameplayTags(TagContainer);
			
            // -> Here we evaluate the condition but we dont set the flag to false
            if (TagContainer.MatchesQuery(PreviousGameplayTagQuery))
			{
				bPreviousMatches = true;
			}
		}
		else
		{
			bPreviousMatches = false;
		}
	}

	// same for the bNextMatches
    ...

	return bPreviousMatches && bNextMatches;
}

I made the following fix locally to have the wanted result.

bool UGameplayTagTransitionCondition::OnTransitionMatches(const FCameraRigTransitionConditionMatchParams& Params) const
{
	bool bPreviousMatches = true;

	if (!PreviousGameplayTagQuery.IsEmpty())
	{
// If we set a condition we will succeed only if it will be evaluated to true
        bPreviousMatches = false;

		if (Params.FromCameraRig)
		{
			FGameplayTagContainer TagContainer;
			Params.FromCameraRig->GetOwnedGameplayTags(TagContainer);
			if (TagContainer.MatchesQuery(PreviousGameplayTagQuery))
			{
				bPreviousMatches = true;
			}
		}
	}

	bool bNextMatches = true;

	if (!NextGameplayTagQuery.IsEmpty())
	{
        bNextMatches = false;

		if (Params.ToCameraRig)
		{
			FGameplayTagContainer TagContainer;
			Params.ToCameraRig->GetOwnedGameplayTags(TagContainer);
			if (TagContainer.MatchesQuery(NextGameplayTagQuery))
			{
				bNextMatches = true;
			}
		}
	}

	return bPreviousMatches && bNextMatches;
}

Hope it can be useful even if it requires a change on the source code.

Cheers.

2 Likes