InputPressedSpecHandles array is reset and abilities don't trigger (Lyra, Input, AbilitySystemComponent)

I’m making a WheeledPawn able to work with Lyra ASC.

The problem I faced is that I can’t trigger abilities. They are granted, and

void UECRAbilitySystemComponent::AbilityInputTagPressed(const FGameplayTag& InputTag)
{
	if (InputTag.IsValid())
	{
		for (const FGameplayAbilitySpec& AbilitySpec : ActivatableAbilities.Items)
		{
			if (AbilitySpec.Ability && (AbilitySpec.DynamicAbilityTags.HasTagExact(InputTag)))
			{
				InputPressedSpecHandles.AddUnique(AbilitySpec.Handle);
				InputHeldSpecHandles.AddUnique(AbilitySpec.Handle);
				UE_LOG(LogTemp, Warning, TEXT("A Tag %s pressed, adding handle %s, new length %d"),
				       *(InputTag.ToString()), *(GetNameSafe(AbilitySpec.Ability)), InputPressedSpecHandles.Num())
			}
		}
	}
}

lets me know that tag is added to InputPressedSpecHandles (it becomes len 1). But then in void UECRAbilitySystemComponent::ProcessAbilityInput:

UE_LOG(LogTemp, Warning, TEXT("Processing pressed %d"), InputPressedSpecHandles.Num())

Says that InputPressedSpecHandles len is 0. I marked every line with debugger stop point where InputPressedSpecHandles.Reset() is called (constructor, end of ProcessAbilityInput and CancelAbilityInput), nothing triggers between where it’s added and the line where it prints that len is 0. It shouldn’t be Garbage Collector as InputPressedSpecHandles is an array of structures.

However, since InputPressedSpecHandles len is 0 in the process ability input, no abilities are activated by input I send.

I have suspicions that in 1 frame ProcessAbilityInput is called before AbilityInputTagPressed.

No that shouldn’t be issue as the array would the same until the next frame.

I literally commented all .Reset() lines for the array

And still some ■■■■ reduces its len to 0.

The game runs in standalone so no replication issues etc.

Ok, I repalced AddUnique with Add and now it seems there are 2 ASC components even in Standalone…

I finally figured out the issue, there were 2 ASC components within 1 standalone: one on PlayerState (Lyra’s default) and my new one on vehicle. The problem was in the AECRPlayerController::GetECRAbilitySystemComponent() of controller that returned ASC on player state, I rewrote it to get the pawn ASC, not the ps ASC.

UECRAbilitySystemComponent* AECRPlayerController::GetECRAbilitySystemComponent() const
{
	const AECRPlayerState* ECRPS = GetECRPlayerState();
	if (ECRPS)
	{
		if (APawn* MyPawn = ECRPS->GetPawn())
		{
			if (IAbilitySystemInterface* ASI = Cast<IAbilitySystemInterface>(MyPawn))
			{
				if (UECRAbilitySystemComponent* ECRASC = Cast<UECRAbilitySystemComponent>(
					ASI->GetAbilitySystemComponent()))
				{
					return ECRASC;
				}
			}
		}
	}
	return nullptr;
}

Two factors that made the debugging so slow:

  1. I didn’t check that ASC are the same ids while in debugger
  2. GetNameSafe() doesn’t print any ids for c++ classes instances, which is annoying.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.