React From Player With Notifier
Type: Plugin/Engine only
This example is intentionally player-side rather than interactable-side, because IEDInteractionNotifier is designed to be implemented by your Pawn or PlayerController.
Example
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Interfaces/EDInteractionNotifier.h"
#include "MyPlayerCharacter.generated.h"
UCLASS()
class AMyPlayerCharacter : public ACharacter, public IEDInteractionNotifier
{
GENERATED_BODY()
public:
virtual void Local_OnInteraction_Implementation(const FEDInteractionEventContext& Context) override;
virtual void Local_OnInteractionDenied_Implementation(const FEDInteractionEventContext& Context) override;
virtual void Server_OnInteraction_Implementation(const FEDInteractionEventContext& Context) override;
};
#include "MyPlayerCharacter.h"
void AMyPlayerCharacter::Local_OnInteraction_Implementation(const FEDInteractionEventContext& Context)
{
UE_LOG(LogTemp, Log, TEXT("Local interaction with %s"), *GetNameSafe(Context.InteractableActor));
}
void AMyPlayerCharacter::Local_OnInteractionDenied_Implementation(const FEDInteractionEventContext& Context)
{
UE_LOG(LogTemp, Warning, TEXT("Interaction denied. Reason: %d"), static_cast<int32>(Context.DenyReason));
}
void AMyPlayerCharacter::Server_OnInteraction_Implementation(const FEDInteractionEventContext& Context)
{
UE_LOG(LogTemp, Log, TEXT("Server confirmed interaction on %s"), *GetNameSafe(Context.InteractableActor));
}
When to use this instead of actor delegates
Use the notifier when the reaction belongs to the player:
- HUD feedback
- local audio
- tutorial prompts
- analytics
- character-specific logic