How to access blueprint vars in c++?

There are 2 options:

  1. The simplest is to create a C++ base class, add the variables to that, and then create the BP derived from that class. That makes them very easy to access from C++. You will need to mark the variables in the header like this:

    UPROPERTY(BlueprintReadWrite, Category=MyCharacter)
    float MyFloat;

  2. It is possible to find a property by name and then access its value like this:

    UFloatProperty* FloatProp = FindField(Object->GetClass(), PropertyName);
    if(FloatProp != NULL)
    {
    float* FloatPtr = FloatProp->GetPropertyValue_InContainer(Object);
    if(FloatPtr != NULL)
    {
    float MyFloat = *FloatPtr;
    }
    }

1 Like