Hi,
I’m trying to create different interfaces for various interactions like Interaction_Dialog (player can talk to any character that inherits this interface), Interaction_PickUp (player can pick up any object that inherits this interface) etc.
Here is how the .h file looks like for dialog interface
UINTERFACE(MinimalAPI)
class UInteraction_Dialog : public UInterface
{
GENERATED_BODY()
};
class ABaseCharacter;
class ASelloutCharacter;
class PROJECTSELLOUT_API IInteraction_Dialog
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
private:
protected:
public:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interactable|Dialog")
void OnDialogInitiated(ASelloutCharacter* DialogInitiatedBy, ABaseCharacter* DialogInitiatedTo);
virtual void OnDialogInitiated_Implementation(ASelloutCharacter* DialogInitiatedBy, ABaseCharacter* DialogInitiatedTo);
UFUNCTION(Client, Reliable, Category = "Interactable|Dialog")
virtual void Client_OnDialogInitiated(ASelloutCharacter* DialogInitiatedBy, ABaseCharacter* DialogInitiatedTo);
virtual void Client_OnDialogInitiated_Implementation(ASelloutCharacter* DialogInitiatedBy, ABaseCharacter* DialogInitiatedTo);
};
The NPC character inherits IInteraction_Dialog and the NPC character is replicated.
OnDialogInitiated is triggered in server and server checks conditions and then tell client to do its things.
But the Client_OnDialogInitiated RPC is never called on client and its called in server as if its a normal function.
Since a character that is replicated is inheriting the interface I assumed that RPCs should work. Does RPCs don’t work while calling inside Interface? Do I have to make this into UActorComponent?
I really wanted to avoid using UActorComponent as it comes with lots of virtual inherited functions that I don’t need and wasting CPU cycles on them.
I also didn’t want to create functions inside character and then calling them from the UInterface because I wanted these Interfaces to be self contained.
Thanks.