Bind a function to a delegate with preset params

Hey all,

I’m setting up a stamina system and I’m trying to work around how I can bind a function with parameters to a delegate.

In my code, I declare the delegate:

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStaminaDepleted);

UPROPERTY(BlueprintAssignable)
FOnStaminaDepleted OnStaminaDepleted;

I have the sprint function (among many I’ll make down the line) that I want to be called with the value automatically set to false.

void Sprint(bool ToggleAbility);

I’m sure there must be a way to bind a function with an param to param-less delegate and preset it so that whenever the delegate is broadcast, it calls the function and passes false to it.

Any help would be appreciated.

Thanks!

I don’t think this is possible with a dynamic delegate.
Those only support binding to UFunctions as they are called by name and via ProcessEvent, which expects all function parameters to be packed in.

Only with a non-dynamic delegate you could bind to a Lambda.

1 Like

Hmmmm…Could be an issue, since non-dynamic delegates don’t support BP integration.

Thank you nonetheless.