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"

How do I trigger a blueprint's function from C++?

I have a blueprint function SaySomething(FString Speech) which, when triggered, displays Speech's text in a randomly selected text block from my UI, then hides it after a few seconds:

alt text

Where I'm getting stuck is executing the function- is there a way I can call SaySomething from one of my C++ modules, instead of using it in blueprint?

Product Version: UE 4.8
textblueprint.png (251.5 kB)
more ▼

asked Jul 28 '15 at 08:17 PM in Blueprint Scripting

avatar image

276 97 67 84

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

2 answers: sort voted first

If you use BlueprintImplementableEvent you can call the function in C++ and define the body of the function in blueprint. By defining the function like this in C++...You'll be able to add the event node for it in blueprint.

 UFUNCTION(Category = "Whatevs", BlueprintImplementableEvent)
 void SaySomethingEvent(FName Speech);
more ▼

answered Jul 28 '15 at 08:26 PM

avatar image

131 6 7 18

avatar image HInoue Jul 28 '15 at 09:25 PM

Ooh, thank you! Just one follow-up: I've been looking over the example in https://wiki.unrealengine.com/Blueprints,_Empower_Your_Entire_Team_With_BlueprintImplementableEvent#Sending_Data_to_Blueprints_From_C.2B.2B after looking up BlueprintImplementableEvent, and how does he actually get the event (red node, Player Health in the tutorial, SaySomethingEvent in your example)? I pasted your example verbatim into a module, compiled it successfully, then opened a blueprint, but even with context turned off, I can't see the SaySomethingEvent node as a suggestion.

avatar image THREEONEZERO Jul 28 '15 at 09:58 PM

Should be under Add Event. Are you trying to add the node in a child blueprint or from another blueprint?

avatar image HInoue Jul 28 '15 at 10:11 PM

I found it in Call Function, but it expects a white Execution line going in, so I assume that's not it. The code declaring it is in a ActorComponent that every character who can talk has, and the blueprint I'm trying to hook the function to is a UMG UserWidget, an instance of which gets created on every character at runtime.

avatar image eagletree Jul 28 '15 at 11:38 PM

Events you have called from your C++ should show up as red event boxes when brought into the blueprint. If they are not there, possibly the hot reload did not update your editor. Close the editor and reopen to see. In fact, on the mac, you always have to do this to get events to show up in the selection box of the blueprint. As THREEONZERO said, be sure you are attempting to find the event in a blueprint derived from your C++ class.

avatar image HInoue Jul 29 '15 at 12:34 PM

I'm a moron, I was expecting a blueprint not derived from the C++ class to still see it- reorganizing things a bit fixed it perfectly, thank you so much! :)

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

Hmmm - I've got all my events as virtual functions in C++ - Example:

 UFUNCTION(BlueprintImplementableEvent, Category = Action, meta = (DisplayName = "StartEffects"))
     virtual void BP_StartEffects(EEffectTypes effectType);

My blueprint callable functions are not:

 UFUNCTION(BlueprintCallable, Category = Action)
     void Clicked();
more ▼

answered Jul 28 '15 at 11:18 PM

avatar image

1.3k 61 70 271

(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