Getting variable from blueprint to c++

Is it possible to somehow get the variable value form blueprint to c++ variable? I don’t need to change it in blueprint via c++, only get the value.

Hey DrewDebelo,

Its possible but you need to create a C++ class with a UPROPERTY( BlueprintReadWrite ) variable and then create a Blueprint class from that C++ class.

Then, from the Blueprint, assign that variable and then in the code for C++ you can use it. I usually do something like this when I need a reference to the root UCanvasPanel for UserWidgets.

And if i already have the blueprint class and variables?

Does the Blueprint class extend a C++ class?

No, i have a character c++ class, and have a blueprint class, and this blueprint class has a variable which i need to read in c++ character class. As i can guess this is not possible, unless i make a blueprint extension for c++ character and cast from the blueprint with variable to this extension to get this variable and use it. Well actually i have already had all this stuff working using only blueprints, but now there is a necessity to recreate character, ai and everything related to it in c++, but blueprint where the needed variable sets is something i won’t be able to reproduce in c++ (it’s from marketplace and i’m only getting started with c++), so…i stuck here
Hope this mess of words is possible to understand.
Thanks.

What is the Blueprint class that you are using? You can still make a C++ class for it and just copy the Blueprint already done into the new Blueprint class coming from the C++ class you’ve made.

Is it possible to make an empty character c++ class, AIController c++ class, make al the AI stuff in c++ then inherit a blueprint from this class and set up everything else?

Yeah. That is generally the work flow, to do the bulk of the classes logic in C++ then setup what you want (such as SkeletalMeshComponents, Particle Systems, and Sounds) in the Blueprint class.

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

Hey, I am having the same issue as the original poster. I understand the workflow but I do not know how to write the code, I just need to get a mesh and material from the blueprint to use in the c++ class, How would I go about that?