How to do it...

  1. Create a new Actor class called TimeOfDayHandler, as shown in the following screenshot:
  1. Add a multicast delegate declaration to the header:
DECLARE_MULTICAST_DELEGATE_TwoParams(FOnTimeChangedSignature, int32,                                      int32)UCLASS()class CHAPTER_05_API ATimeOfDayHandler : public AActor
  1. Add an instance of our delegate to the class declaration in the public section:
FOnTimeChangedSignature OnTimeChanged; 
  1. Add the following properties to the class:
UPROPERTY() 
int32 TimeScale; 
 
UPROPERTY() 
int32 Hours; UPROPERTY() 
int32 Minutes; 
 
UPROPERTY() 
float ElapsedSeconds; 
  1. Add the initialization of these properties to the constructor: ...

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.