# How to access blueprint vars in c++?

**URL:** <https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331 "2014-03-11T02:12:06Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/1 "2014-03-11T02:12:06Z")

</div>

How can I acces vars I’ve created in my Character’s blueprint in the c++ character class code?

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/2 "2014-03-11T02:12:07Z")

</div>

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:

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

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/3 "2014-03-11T02:12:07Z")

</div>

Thanks so much for the answer James!

You’re awesome!

🙂

Rama

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/4 "2014-03-11T02:12:08Z")

</div>

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

I got this working!

I am using

```
SetPropertyValue_InContainer

```

to update my foot placement system

**Is there an equivalent for UFloatProperty for vectors?**

I tried UVectorProperty to no avail 🙂

**and where is the .h file for UFloatProperty?**

I bet I can find lots of answers there if I know where to look in the header files

🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/5 "2014-03-11T02:12:08Z")

</div>

Ah, Vector is a Struct, so you need a UStructProperty, like this:

```
UScriptStruct* VectorStruct = FindObjectChecked(UObject::StaticClass(), TEXT("Vector"));
UStructProperty* VectorProp = FindField(Object->GetClass(), PropertyName);
if(VectorProp != NULL && VectorProp->Struct == VectorStruct)
{
	*VectorProp->ContainerPtrToValuePtr(Object) = Value;
}

```

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/6 "2014-03-11T02:12:09Z")

</div>

Thanks so much James for taking the time!

I will be doing tutorial for rocket forum utilizing this info you are sharing with me,

as soon as I have good examples all set up!

-Rama

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/7 "2014-03-11T02:12:09Z")

</div>

Like I said, in my opinion the easiest (and most efficient) way to do this is to add the variables in a C++ base class instead of finding them by name, but both work.

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/8 "2014-03-11T02:12:10Z")

</div>

I tried doing that, but I could not figure out how to add variables to my AnimBlueprint in C++, or how to get custom variables from my extended Character c++ class into the Animblueprint:

[https://rocket.unrealengine.com/questions/4932/how-do-i-extend-animblueprint-to-set-variables-via.html](https://rocket.unrealengine.com/questions/4932/how-do-i-extend-animblueprint-to-set-variables-via.html)

🙂

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:12am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/9 "2014-03-11T02:12:10Z")

</div>

Nvm, I figured out now, thanks James Golding!

tutorial on rocket forum:  
[http://forums.epicgames.com/threads/972861-Tutorial-Compile-C-for-UE4-Code-Samples-For-You-(New-Create-Material-Instances)?p=31653957&viewfull=1#post31653957](http://forums.epicgames.com/threads/972861-Tutorial-Compile-C-for-UE4-Code-Samples-For-You-(New-Create-Material-Instances)?p=31653957&viewfull=1#post31653957)

---

<div class="post-metadata">

**Author:** ![Xosh\_project](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xosh\_project](https://forums.unrealengine.com/u/Xosh_project)\
**Post date:** [May 3, 2016, 11:09pm UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/10 "2016-05-03T23:09:11Z")

</div>

Hey James and Rama, this is exactly what I need but I don’t have a lot of experience with C++. Unfortunately I can’t acces to «[http://forums.epicgames.com/threads/972861-Tutorial-Compile-C-for-UE4-Code-Samples-For-You-(New-Create-Material-Instances)?p=31653957&viewfull=1#post31653957»](http://forums.epicgames.com/threads/972861-Tutorial-Compile-C-for-UE4-Code-Samples-For-You-(New-Create-Material-Instances)?p=31653957&viewfull=1#post31653957%C2%BB). They say I don’t have permission to acces to this page. Just wanted to know if there a way for me to get the tutorial.

Thanks and have a good day.

---

<div class="post-metadata">

**Author:** ![emperor\_katax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/emperor_katax/32/1070178_2.png) [@emperor\_katax](https://forums.unrealengine.com/u/emperor_katax)\
**Post date:** [December 22, 2018, 11:02am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/11 "2018-12-22T11:02:21Z")

</div>

Check this:

> **[Get / Set variables by Name | Shooter Tutorial](http://shootertutorial.com/2016/03/20/get-set-variables-by-name/)**

---

<div class="post-metadata">

**Author:** ![Cpt\_Atoom](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cpt_atoom/32/469955_2.png) [@Cpt\_Atoom](https://forums.unrealengine.com/u/Cpt_Atoom)\
**Post date:** [March 1, 2022, 4:10am UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/12 "2022-03-01T04:10:01Z")

</div>

Hello, I’m a little bit late but these topic doesn’t exist anymore and i cannot find anything talking about that except here 😕  
If sometone get it, can you explain it to me please ?

---

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [March 8, 2022, 1:48pm UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/13 "2022-03-08T13:48:22Z")

</div>

explain what? [How to access blueprint vars in c++? - #2 by ue4-archive](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/2)

is probably the best answer on the topic.

---

<div class="post-metadata">

**Author:** ![Cpt\_Atoom](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cpt_atoom/32/469955_2.png) [@Cpt\_Atoom](https://forums.unrealengine.com/u/Cpt_Atoom)\
**Post date:** [March 8, 2022, 4:05pm UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/14 "2022-03-08T16:05:27Z")

</div>

Hi @eblade 😃 FindField is deprecated ([FindField | Unreal Engine Documentation](https://docs.unrealengine.com/4.27/en-US/API/Runtime/CoreUObject/UObject/FindField/2/))  
it say "FindField will no longer return properties. Use FindFProperty instead or FindUField if you want to find UFunctions or UEnums. "

I don’t understand because i used FindFProperty and it returned nothing…

---

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [March 8, 2022, 7:01pm UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/15 "2022-03-08T19:01:30Z")

</div>

Without an example, it’s pretty difficult to advise. In general, though, attempting to do that is most likely the wrong way to achieve what you want to do.

If the C++ needs to access a variable that isn’t declared until later, then … you should move that variable.

---

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [March 8, 2022, 7:05pm UTC](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/16 "2022-03-08T19:05:35Z")

</div>

```auto
	FProperty* P0 = FindFProperty<FProperty>(GroomAsset->GetClass(), GET_MEMBER_NAME_CHECKED(UGroomAsset, HairGroupsInterpolation));

```

and

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/4/eb4233b2aeafd4e84b79da8275eb7f551968935f.png)

if that helps inform you how to use it
