How to do it...

  1. Create a UInterface/IInterface called Killable:
  1. Add UINTERFACE(meta=(CannotImplementInterfaceInBlueprint)) to the UInterface declaration:
// This class does not need to be modified.UINTERFACE(meta = (CannotImplementInterfaceInBlueprint))class UKillable : public UInterface{  GENERATED_BODY()};
  1. Add the following functions to the header file under the IKillable class:
class CHAPTER_07_API IKillable{    GENERATED_BODY()    // Add interface functions to this class. This is the class that     // will be inherited to implement this interface.public:    UFUNCTION(BlueprintCallable, Category = Killable)    virtual bool IsDead(); UFUNCTION(BlueprintCallable, ...

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.