Creating a delegate that takes input parameters

So far, the delegates that we've used haven't taken any input parameters. This recipe shows you how to change the signature of the delegate so that it accepts some input.

Getting ready

Be sure you've followed the recipe at the beginning of this chapter, which shows you how to create a TriggerVolume and the other infrastructure that we require for this recipe.

How to do it...

  1. Add a new delegate declaration to GameMode:
    DECLARE_DELEGATE_OneParam(FParamDelegateSignature, FLinearColor)
  2. Add a new member to GameMode:
    FParamDelegateSignatureMyParameterDelegate;
  3. Create a new Actor class called ParamDelegateListener. Add the following to the declaration:
    UFUNCTION() void SetLightColor(FLinearColorLightColor); UPROPERTY() ...

Get Unreal Engine 4 Scripting with C++ Cookbook 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.