0

A bit new to Unreal/C++, tried to find some info about my question on Google but no luck here :( So need some guidance :) I'm trying to pass a function as a parameter to another function. Syntax doesn't show any errors but when I'm trying to build a solution I've got an error :

  [C2064] term does not evaluate to a function taking 2 arguments

Appreciate any help! :)

`

void UPlayerUI::CallUpdateIconSlot(TEnumAsByte<EDamageClass> DamageClass, bool bIsActive, float DeltaTime)
{
    UpdateSlotIcon(DamageClass, bIsActive, DeltaTime, &UPlayerUI::UpdateIcon);
}

void UPlayerUI::UpdateSlotIcon(TEnumAsByte<EDamageClass> DamageClass ,bool bIsActive, float DeltaTime, float(UPlayerUI::*UpdateOpacity)(float, float))
{
    if (bIsActive)
    {
        for (auto IconSlot : Slots)
        {
            if (IconSlot.Value == DamageClass)
            {
                const float CurrentOpacity = IconSlot.Key -> ColorAndOpacity.A;
                IconSlot.Key -> SetOpacity(*UpdateOpacity(CurrentOpacity, DeltaTime));
            }
            else
            {
                UE_LOG(LogTemp, Error, TEXT("Huston we have a problem"));
            }
        }
    }
}

float UPlayerUI::UpdateIcon(float PCurrentOpacity, float DeltaTime)
{
    if (PCurrentOpacity == Opacity.Get<1>())
    {
        Opacity = MakeTuple(Opacity.Get<1>(), Opacity.Get<0>());
    }

    return FMath::FInterpConstantTo(PCurrentOpacity, Opacity.Get<1>(), DeltaTime, .75f);
}

`

In this line that causes an error: IconSlot.Key -> SetOpacity(*UpdateOpacity(CurrentOpacity, DeltaTime));

tried:

this -> (*UpdateOpacity)(CurrentOpacity, DeltaTime)

But getting other errors.

Botje
  • 26,269
  • 3
  • 31
  • 41
hof13nn
  • 1
  • 2
  • Should've been like this: `IconSlot.Key -> SetOpacity((this->*UpdateOpacity)(CurrentOpacity, DeltaTime));` – hof13nn Dec 01 '22 at 10:40

0 Answers0