Creating dynamic input delegates

So, for the past few days I have been trying to hunt down how UE4 handles delegates, more specifically the ones that are not defined as BlueprintImplementableEvent within the class (the input delegates). I managed to get a decent understanding of how the engine handles things, but there is one thing that still escapes me; how the Actor class generates the input delegates.

I have noticed the following code in the AActor class:

DECLARE_DELEGATE_RetVal_ThreeParams(bool, FOnProcessEvent, AActor*, UFunction*, void*);

I kinda get the other delegates in the class, but I don’t understand what this one does. I know it has a relation with the ProcessEvent function in AActor, but I cannot find anywhere how it is called and what it is responsible for. I did manage to track down the FOnProcessEvent to some utility classes, but that only made me more confused.

Essentially, what I want to know is the following:

  • What does this delegate do?
  • How does it do it?
  • What is the FOnProcessEvent good for? I have found other delegates with an F signature, but this one is the odd one out, since I could actually trace it back to somewhere else in the code.
  • If necessary: How would I go making a custom FOnProcessEvent?
  • If none of this has anything to do with input delegate generation, then where can I find that functionality? Other than that, I wasn’t able to find anything else.

What I want to be able to do is the following; to be able to generate a custom blueprint, not based on the actor class, where you are able to place an input event (either axis or action) in the blueprint graph. I have already explored options of making my own blueprint graphs but from what I managed to understand, that won’t solve my problem (not to mention kinda out of my league).

Is there anyone who can help me out?

Bump. Still really wish to know the answer. No one out there who knows?

From what I can see, this is done at a pretty low level and would be tough to extend to non-actor types.

It looks like the method UBlueprint::SupportsInputEvents() is what determines whether to allow input bindings to be added in a blueprint. The default implementation of this bases it on whether or not the blueprint parent class is an actor type. So at the very least, you’d have to derive a new kind of blueprint from UBlueprint and override this method. That in itself wouldn’t be too big a task, but you’d then need to set up the additional code required to make the editor use your specialized blueprint when creating blueprint classes from your particular base class.

Probably more of a problem though, is that to make use of the bindings, there is a call in Actor.cpp to UInputDelegateBinding::BindInputDelegates, which requires a UInputComponent. Obviously, components are restricted to actors, so I don’t know how you’d get around that. I guess whatever created your object would have to be responsible for passing it a pointer to an input component, such as the one on the player controller.

It would be a whole lot less work to just base your class on AActor instead.

Thanks a whole lot! To think I completely overlooked something so obvious.

The problem is that I have tried working with the AActor class since, as you say, it is way easier than having to implement your own system. The problem though is that for what I need I really need to have components; I cannot put actors as components in an actor. Otherwise the point behind the functionality is lost. Though, I did experiment earlier with generating an input component on an component and succeeded in at least the component generation. That is, I got the component to spawn and was able to trace a pointer to the component. Whether this means I can get the binding to work is a different matter, but time will tell. At the very least, if I cannot get dynamic input delegates into the component, I won’t have anything to bind to begin with.