Custom global c++ blueprint event
I'm new to Unreal Engine and I wanted to know, how do I create a custom c++ event that shows up everywhere in blueprint (like Every tick or Begin play etc) and how and where do I fire it (or if it is even possible)? I can only get my own classes extended from AActor to have blueprint callable functions, but to do blueprint global events in c++ is something that I can't really wrap my head around.
asked Apr 10 '14 at 06:17 AM in C++ Programming
In the essence these events are you posted as examples are not global ;). They are just implemented high in inheritance tree. (in AActor as far as I remember).
To be clear. the highest accessible member on inheritance tree is UObject, declared in Obj.h. If you really want some event accessible everywhere, you will need to modify this class. I highly recommend to do not do it!
Make sure you really need that event everywhere.
Fire up events is actually simple.
Lets just look at Tick Event in the essence you declare it like this:
Then you want it to tick, every frame. So you look for void Tick(float DeltaTime) function, and simply add this event to it like:
Voila! you have you event, that is triggered every frame. You do it similarly for other events. You add them to functions that perform specific action (like reload weapon).
if you want to have Ticker event in class derived from UObject you need to implement custom ticker.
You can take look here:
How I have done it. Look for classes RPGEffectBase.
There are also Delegate Events, but that is whole different topic, and those events can be really global, but their usage in Blueprint is harder and in most cases you don't need them, though they can make your C++ somewhat more clear (Aside from macros used to declare them).
You can take look at simple delegate event in RPGCharacter:
Follow this question
Once you sign in you will be able to subscribe for any updates here