How to do it...

  1. Create a new interface called Interactable.
  2. Add the following functions to the IInteractable class declaration:
class CHAPTER_07_API IInteractable{    GENERATED_BODY()    // Add interface functions to this class. This is the class that     // will be inherited to implement this interface.public:    UFUNCTION(BlueprintNativeEvent, BlueprintCallable,               Category = Interactable)    bool CanInteract();    UFUNCTION(BlueprintNativeEvent, BlueprintCallable,               Category = Interactable)    void PerformInteract();};
  1. Create a second interface, Openable.
  2. Add this function to its declaration:
class CHAPTER_07_API IOpenable{  GENERATED_BODY()  // Add interface functions to this class. This is the class that  // will be inherited to implement this interface. ...

Get Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.