I’m looking at someone else’s code and I find this. It’s a static function call from an interface, oddly enough, a function generated by the Unreal Build Tool. Is this common practice? Aren’t there less obscure ways to do these things?
The context, a function on the PlayerController bound to pressing the E key. That function is Action.
I have seen that the method declared in the interface is a BlueprintNativeEvent, is it calling that method generated by the UHT to directly call the blueprint “event”, and that said event calls the correct method?
void AHowToCharacter::Action()
{
if (CurrentInteractive != nullptr)
{
// Execute the interact event
IInteractable::Execute_OnInteract(CurrentInteractiveActor);
}
}
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "Interactable.generated.h"
UINTERFACE(MinimalAPI)
class UInteractable : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class HOWTO_API IInteractable
{
GENERATED_BODY()
public:
virtual FName GetName() = 0;
virtual FName GetQuestID() = 0;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Interact")
void OnInteract();
};