This recipe will show you how to combine a number of other recipes in this chapter to demonstrate a simple interaction system, and a door with an interactable doorbell to cause the door to open.
Create a new interface,
Interactable
.Add the following functions to the
IInteractable
class declaration:UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category=Interactable) boolCanInteract(); UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = Interactable) voidPerformInteract();
Create default implementations for both functions in the implementation file:
boolIInteractable::CanInteract_Implementation() { return true; } voidIInteractable::PerformInteract_Implementation() { }
Create a second interface,
Openable
.Add this function to its declaration:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category=Openable) void Open();
As with
Interactable
, create a default implementation for theOpen
function:voidIOpenable...