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"

Run function on blueprint game instance from C++ class

I am create custom console commands using C++. All the logic is within a blueprint game instance. How could i find and call these functions within C++

Product Version: UE 4.21
more ▼

asked Nov 20 '18 at 11:23 PM in C++ Programming

avatar image

Sam Carey
49 2 5 7

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

2 answers: sort voted first

It is almost always a good idea to have c++ parents for core gameplay classes such as game mode, game state, player controller etc. including game instance, where you can write some heavy methods or expose c++-only features to blueprints. I suggest you create base c++ game instance and move necessary methods there.

Otherwise, you cannot directly call anything from bp in c++ but you can use delegates. However, this approach is a bit messier for project architecture

more ▼

answered Nov 21 '18 at 05:29 AM

avatar image

345 4 4 12

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

Hi @Sam_Carey. I have never seen a way to do this... mainly because the blueprint logic doesn't exist during C++ compile time. However, you can create a BlueprintNativeEvent or broadcast a delegate as a BlueprintAssignableEvent and assign the logic in the blueprint to that delegate

In this scenario, I would use a blueprint native event. That way, you can have the native implementation throw a log to the console output in case you forget to override it in your blueprint class. To override the function in your blueprint, just go to the overrides drop down and select your event.

Have fun

more ▼

answered Nov 21 '18 at 12:16 AM

avatar image

275 8 9 16

avatar image Sam Carey Nov 22 '18 at 06:34 AM

I have tried your suggestion, however I am receiving some strange errors. Would you have any what is causing this?

alt text

ue4-errors.png (1.1 MB)
avatar image Hustlan Nov 22 '18 at 08:20 AM

When you define BlueprintNativeEvents in C++, the name of the event is going to be OriginalName_Implementation. Event with OriginalName is already present but is only for Blueprints, that's why you get this error.

(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