How to easily change Default Events to Fit your Needs

Miguel Fernández
Trunk of Code
Published in
2 min readMay 14, 2017
Custom default events on your actor

If you are familiarized with UE4 and you are a programmer, you have probably thought more than once:

Wouldn’t it be awesome to define my own default events for my awesome actors?

Well, you can. And it’s quite simple once you know how.

Editor Module

Before anything else, this event registration needs to be done though an Editor Module.

There’s a page on the wiki, ‘Creating an Editor Module’ by Karltheawesome, that describes this process very well, just in case you don’t have one on your project.

Registering Default Events

With that being said, the only thing we need to do is to add some changes to our editor module.

MyEditorModule.h

Inside ‘EditorModule.h’ we will only add a function where we will contain all our event registrations

void PrepareAutoGeneratedDefaultEvents();

and a macro that allows us to register them

#define RegisterDefaultEvent(Class, FuncName) ...

MyEditorModule.cpp

Inside our .cpp file, we will call RegisterDefaultEvent for each event we want to set as default.

RegisterDefaultEvent(AMyActor, MyEvent);//Some examples:
RegisterDefaultEvent(AEnemy, EnteredCombat);
RegisterDefaultEvent(AEnemy, JustDied);

Unregistering Events

Last thing! We must call Unregister function when the module is shutdown to allow the engine to for example hot-reload the plugin.

FKismetEditorUtilities::UnregisterAutoBlueprintNodeCreation(this);

Now you are able of customizing a little bit more your classes. I originally wrote this to remember it to myself but hope it helped to you.

--

--

Miguel Fernández
Trunk of Code

AI Programmer at @FrontwireGames, Jammer, AI enthusiast... Blah..Bla..Bla! @UnrealEngine