# Read variable value from UProperty of different types

**URL:** <https://forums.unrealengine.com/t/read-variable-value-from-uproperty-of-different-types/310731>\
**Category:** Plugins\
**Tags:** unreal-engine, editor, Plugins, CPP, Blueprint, question\
**Created:** [March 12, 2015, 10:42pm UTC](https://forums.unrealengine.com/t/read-variable-value-from-uproperty-of-different-types/310731 "2015-03-12T22:42:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![LinFredriksson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LinFredriksson](https://forums.unrealengine.com/u/LinFredriksson)\
**Post date:** [March 12, 2015, 10:42pm UTC](https://forums.unrealengine.com/t/read-variable-value-from-uproperty-of-different-types/310731/1 "2015-03-12T22:42:19Z")

</div>

Hi.

I am trying to read the variable values from different blueprint components and while I was able to find how to do that for some variable types like float, double, bool and int I am not able to figure out how to do it for anything else. For example variables of type FVector, FRotator or any type of struct/enum/class. So how do I get the variable values for lets say a FVector, and do the other types work the same way?

I found that a FVector is a UStructProperty but I cant manage to access the vectors x, y, and z.

The following example is part of the code I have now where I successfully find bool and float values.

```
UCharacterMovementComponent *c = Cast<UCharacterMovementComponent>(Component);
if (c != NULL)
{
  for (TFieldIterator<UProperty> PropIt(c->GetClass()); PropIt; ++PropIt)
  {
    if (PropIt->IsA(UBoolProperty::StaticClass()))
    {
      UBoolProperty *BoolProp = CastChecked<UBoolProperty>(*PropIt);
      bool CurValue = BoolProp->GetPropertyValue_InContainer(c);
    }
    else if (PropIt->IsA(UFloatProperty::StaticClass()))
    {
      UFloatProperty *NumericProp = CastChecked<UFloatProperty>(*PropIt);
      float CurValue = NumericProp->GetPropertyValue_InContainer(c);
    }
    else if (PropIt->IsA(UStructProperty::StaticClass()))
    {
      UStructProperty *StructProp = CastChecked<UStructProperty>(*PropIt);
      // find values for FVector, FRotator, and so on
    }
  }
}

```

I should also point out that I will use this for a plugin so I have to find the properties from existing blueprints. So creating my own c++ class and use that when creating the blueprints is not an option.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![LinFredriksson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LinFredriksson](https://forums.unrealengine.com/u/LinFredriksson)\
**Post date:** [March 16, 2015, 4:27pm UTC](https://forums.unrealengine.com/t/read-variable-value-from-uproperty-of-different-types/310731/2 "2015-03-16T16:27:08Z")

</div>

I solved it myself by using “UProperty::ContainerPtrToValuePtr”. I had tried it before posting this question but for some reason I could not get it to work on the first try. By using this I successfully read the values from all component properties.

---

<div class="post-metadata">

**Author:** ![Derjyn](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/derjyn/32/931618_2.png) [@Derjyn](https://forums.unrealengine.com/u/Derjyn)\
**Post date:** [August 18, 2016, 3:31pm UTC](https://forums.unrealengine.com/t/read-variable-value-from-uproperty-of-different-types/310731/3 "2016-08-18T15:31:49Z")

</div>

Any chance you can share a little more code? I’ve been banging my head against the wall with trying to get/set FVector by variable name -\_-

---

<div class="post-metadata">

**Author:** ![TooManyCrashes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TooManyCrashes](https://forums.unrealengine.com/u/TooManyCrashes)\
**Post date:** [September 23, 2016, 7:18pm UTC](https://forums.unrealengine.com/t/read-variable-value-from-uproperty-of-different-types/310731/4 "2016-09-23T19:18:54Z")

</div>

You could do it like this:

```
if (UIntProperty* IntProperty = Cast<UIntProperty>(Property))
{
    int32 Value = IntProperty->GetSignedIntPropertyValue(Property->ContainerPtrToValuePtr<int32>(Obj));
    SetIntProperty(Property->GetName(), Value);
}
```

---

<div class="post-metadata">

**Author:** ![intoxicat3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@intoxicat3](https://forums.unrealengine.com/u/intoxicat3)\
**Post date:** [November 23, 2016, 7:19pm UTC](https://forums.unrealengine.com/t/read-variable-value-from-uproperty-of-different-types/310731/5 "2016-11-23T19:19:38Z")

</div>

but how to get properties values from UStructProperty?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_10b75a231](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10b75a231](https://forums.unrealengine.com/u/anonymous_user_10b75a231)\
**Post date:** [May 4, 2017, 2:12am UTC](https://forums.unrealengine.com/t/read-variable-value-from-uproperty-of-different-types/310731/6 "2017-05-04T02:12:50Z")

</div>

Perhaps this answer can help: [Set/Get UProperty inside of USTRUCT directly](https://answers.unrealengine.com/questions/212756/setget-uproperty-inside-of-ustruct-directly.html#answer-596310)
