How to do it...

  1. Inside our Unreal project's GameMode header, declare the delegate with the following macro, just before the class declaration:
DECLARE_DELEGATE(FStandardDelegateSignature)UCLASS()class CHAPTER_05_API AChapter_05GameModeBase : public AGameModeBase
  1. Add a new member to our game mode:
DECLARE_DELEGATE(FStandardDelegateSignature)UCLASS()class CHAPTER_05_API AChapter_05GameModeBase : public AGameModeBase{  GENERATED_BODY()public:    FStandardDelegateSignature MyStandardDelegate;};
  1. Create a new Actor class called DelegateListener:
  1. Add the following to the declaration of that class:
UFUNCTION() void EnableLight(); UPROPERTY() ...

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.