x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: Not Selected
Tags:
more ▼

asked Apr 10 '14 at 06:17 AM in C++ Programming

avatar image

muchitto
1 1 4 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You don't.

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:

 UPROPERTY(BlueprintImplementableEvent, Category = SomeCategory)
 void MyAwsomeTickEvent();

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:

 void Tick(float DeltaTime)
 {
  MyAwsomeTickEvent();
 }

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:

https://github.com/iniside/RPGFramework

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:

 DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnCharacterCast);


more ▼

answered Apr 10 '14 at 06:51 AM

avatar image

iniside
1.6k 105 97 185

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question