What is responsible for event generation in Blueprint?

Partly to educate myself on how to construct more “dynamic” code and partly to create new functionality I think may be useful to the UE4 community, I wanted to know what and where exactly in the source is responsible for making blueprint events possible. I am not talking about the events that you can declare in the header files through the use of either BlueprintNativeEvent or BlueprintImplementableEvent. I am specifically talking about events like Tick or Beginplay, which you can see in pretty much any blueprint class you create.

More specifically, I am especially interested in knowing about 2 particular examples:

  • What exactly is responsible for enabling a blueprint to create input
    based events (i.e. where is the
    functionality that allows any actor
    derivative blueprint to call on the
    axis and action events defined in the
    input.ini).

  • What exactly enables certain blueprint events per default in a
    blueprint class, by showing them in a
    half transparant state, with a note
    attached to them that says “This node is disabled and will not be called. Drag off pins to build functionality.”

No matter how deep I dig into the source code, I cannot seem to find anything about it, which I suspect is mostly just my lack of ability to comprehend it at my current level. The way I have understood it so far is that somewhere the data is stored that can allow someone to call on them in Blueprint (possibly through UFunction instances, but I am not sure about that). When the game starts, the code collects all the created events and (if it is an input event) binds them to a specific key. I reckon that the latter is what the InputComponent is responsible for. I am almost completely in the dark about the “during editor” bit.

Is there anyone out there able to explain this to me?

“I am not talking about the events
that you can declare in the header
files through the use of either
BlueprintNativeEvent or
BlueprintImplementableEvent. I am
specifically talking about events like
Tick or Beginplay, which you can see
in pretty much any blueprint class you
create.”
No matter how deep I dig into the source code, I cannot seem to find
anything about it, which I suspect is
mostly just my lack of ability to
comprehend it at my current level"

They are BlueprintImplementableEvent :slight_smile: You could not find them because they are under diffrent name, so there C++ events are not scared with ugly “_Implementation” surrfix (which recently happened to some AGameMode functions) as if you declere C++ functions as events they can not be direcly overriden. They are deleclere in AActor class do every Actor blueprint will have them, here oyu have links for there decleres:

https://github.com/EpicGames/UnrealEngine/blob/b281c38557ad245450fe44f39b9ae28fea3cbe97/Engine/Source/Runtime/Engine/Classes/GameFramework/Actor.h#L1116

https://github.com/EpicGames/UnrealEngine/blob/b281c38557ad245450fe44f39b9ae28fea3cbe97/Engine/Source/Runtime/Engine/Classes/GameFramework/Actor.h#L1150

In cpp file on Tick() and BeginPlay() those bluepritn events are called

https://github.com/EpicGames/UnrealEngine/blob/b281c38557ad245450fe44f39b9ae28fea3cbe97/Engine/Source/Runtime/Engine/Private/Actor.cpp#L2802

https://github.com/EpicGames/UnrealEngine/blob/b281c38557ad245450fe44f39b9ae28fea3cbe97/Engine/Source/Runtime/Engine/Private/Actor.cpp#L738

Thats why if you don’t call Super on those events in C++ it breaks the blueprint events because they won’t be called anymore

Now on point quastions:

Every node that has diffrent icon then “f” it’s a custom nodes and you should search those around those classes:

Key event is here

Also note that some blueprint stuff have “K2” in name (i think this includes huge portion of blueprint graph code) it’s comes from Kismet 2.0, because Blueprint replaces Kismet from UE3 and Epic didn’t change the name to not break the code.

As for default node my guess is it adding nodes in graph editor code, there a function dedicated to that which all graph editor use called CreateDefaultNodesForGraph

But now i look at it i can’t find it, either way it somewhere here https://github.com/EpicGames/UnrealEngine/tree/a27ad66f0a075f3b74ef8f68a4b2b0da4882425e/Engine/Source/Editor/BlueprintGraph/Private

I also don’t know if you will be able to modify or override this behavior other way then createing you own graph editor (which Animation and Widgit Blueprints does). Graph editor code as pretty much all editor code is a lot harder to work with some prepare for some headacks if you want to dig this out and do something with it, i’m learning graph editor framework myself so i know the pain :stuck_out_tongue:

If you ever gonna play with this importent thing to understand is graph data, the nodes in the graph is like source code data, which diffrent code converts to proper data used in the runtime (i think i ncase of K2Nodes compile code… atleast information how to compile them is in node classes) and they are not contained in game, just resulting data. It’s something you need to know because if you start to associate real data with graph data you will get confused.

You might also consider delegates, they allow to create more global events, AActor i linked got good examples

Thanks for the speedy reply!

Thanks to it, I think I am starting to understand how Blueprint works (at least, the flow, which is already way more than I knew before you answered) and if I am not mistaken, it does seem I made some major faulty assumptions about the workings of Blueprint. I also found that rather than InputComponent, the classes responsible for actually generating the input nodes are InputSettings (for getting the data from the ini) and InputSettingsDetails (for generating the required slate components and saving the binding). So, that answers my question about where the initial generation of the input happens. Managed to find those by tracing back the input classes you provided.

I also kinda wanted to know where and when exactly the engine populate the right click menu with the events you can put into a certain blueprint, but with the new knowledge, it seems I am starting to close in on the place that is responsible for populating the right click menu (I already found SBlueprintActionMenu::CollectAllActions, so it’s possibly not much longer before I get there).

As an addition to the previous reply, I found where the default event nodes are actually determined. For anyone who’s interested:

It’s not in the code, it’s in the configuration files. To be more precise, it can be found in the BaseEditorPerProjectUserSettings.ini in the Engine/Config folder (of the source code, not your own project). In there is a section named [DefaultEventNodes], which is where all the default nodes are defined.