How do I access blueprint variables in a C++ class?

Hello,

Is there a way for me to access a blueprint’s variables in a C++ class?

The C++ class is a component of the Pawn Blueprint that has the variables.

I want to access LeftController and RightController so I can get their positions.

Thanks!
Skout

295765-1.png

295766-2.png

295768-3.png

Most easiest way, if you have C++ base class for blueprint is to declare those variables in C++ and make them Blueprint accessible ( UPROPERTY(EditAnywhere,BlueprintReadWrite) first makes varable accessible in property editor, 2nd makes variable settable and gettable in blueprint, it wont be visible on variable list you need to search the nodes you need to search nodes, there also different access modes you can choose). This way variables physically exist in C++ and can be accessed in blueprint and it does not matter if you set them in blueprint.

Without physically declering variable in C++ you need to read and write from uproperty object representing the variable that you can get from UClass of class

Then cast it to proper UProperty type and read out (you can follow API refrence links).

But i really recommend first option, use 2nd only if you don’t have other options