How can I properly call interface over array of actors? I’m searching for most simple example, something in this terms:
TArray<AActor*> MyActors;
float sumValue;
....
for (auto act: MyActors)
{
ISumInterface* sumInterface = Cast<ISumInterface>(act);
if (sumInterface) {
sumValue += sumInterface->SumFunction(); // SumFunction does not take any arguments but return float value.
}
}
Is above code valid? I’m trying to use it from UObject to call this function on other actors that implement that particular interface and obtain results.