How to include bp class into cpp code

I need to get variable from my BP Character in CPP Component. Character is owner of this component. I just want to crate BPCharacter *Variable = GetOwner(); , but I don’t know 1) is it possible? 2) if yes, how to include BP class to CPP code.

Your C++ classes shouldn’t request anything from BPs that isn’t exposed through UFUNCTIONS/UPROPERTIES, if you need that you should implement an interface and have your BP inherit from that.

You can’t do what you’re describing. But you can get to the same place a few different ways. Here’s the easiest way.

Suppose the variable you want to get from the BP_Character is of type int32.

Within your CPP Component class, create a function like this:

UFUNCTION(BlueprintImplementableEvent)
int32 GetIntFromBPCharacterClass();

Next, in the Editor, create a blueprint class that is a child of your CPP Component class (if you don’t have one already). Make sure this BP_Component class is the one that is attached to your BP_Character as opposed to the C++ class.

In your BP_Component class, implement the GetInntFromBPCharacterClass function and use it to return the relevant integer variable from the BP_Character class.

Now, the .cpp file of your CPP Component class, whenever you want the value of the int32 variable, just call the GetIntFromBPCharacterClass() function.