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++
asked Nov 20 '18 at 11:23 PM in C++ Programming
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
answered Nov 21 '18 at 05:29 AM
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.
answered Nov 21 '18 at 12:16 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here