How to get the return value of a function called from another actor inside a function

Hi,

I’m attempting to call a function inside a function and return the return value of that inner function. I’ve had a search but couldn’t find the correct syntax to do this, I’m relatively new to C++ and I think this is likely to be something rather basic but I cannot find it anywhere.

The code below returns an empty FGameplayAbilitySpecHandle, which isn’t surprising as I don’t think it’s taking the return value for GiveAbility and is just returning a null value. How would I go about getting the return value from GiveAbility in order to return it from the outer GiveAbility function in this situation? (I have just realised the naming has made this more confusing)

FGameplayAbilitySpecHandle AGASPlayerState::GiveAbility(class TSubclassOf<UGASGameplayAbility> NewAbility)
{
	if (HasAuthority() && AbilitySystemComponent)
	{
			AbilitySystemComponent->GiveAbility(
			FGameplayAbilitySpec(NewAbility, 1, static_cast<int32>(NewAbility.GetDefaultObject()->AbilityInputID), this));
			return FGameplayAbilitySpecHandle();
	}
	else return FGameplayAbilitySpecHandle();
}

AbilitySystemComponent->GiveAbility returns a FGameplayAbilitySpecHandle so it should just be:

FGameplayAbilitySpecHandle AGASPlayerState::GiveAbility(class TSubclassOf<UGASGameplayAbility> NewAbility)
 {
     if (HasAuthority() && AbilitySystemComponent)
     {
             return AbilitySystemComponent->GiveAbility(
             FGameplayAbilitySpec(NewAbility, 1, static_cast<int32>(NewAbility.GetDefaultObject()->AbilityInputID), this));
     }
     else return FGameplayAbilitySpecHandle();
 }

That’s worked great thank you!

Hi, I simply want to expose clear ability to blueprints basen on Index defined at grant ability stage, I’am blueprinter and if anyone can help I will be grateful.