x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Read variable value from UProperty of different types

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.

Product Version: Not Selected
Tags:
more ▼

asked Mar 12 '15 at 10:42 PM in C++ Programming

avatar image

LinFredriksson
16 3 4 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Mar 16 '15 at 04:27 PM

avatar image

LinFredriksson
16 3 4 5

avatar image Derjyn Aug 18 '16 at 03:31 PM

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 -_-

avatar image TooManyCrashes Sep 23 '16 at 07:18 PM

You could do it like this:

 if (UIntProperty* IntProperty = Cast<UIntProperty>(Property))
 {
     int32 Value = IntProperty->GetSignedIntPropertyValue(Property->ContainerPtrToValuePtr<int32>(Obj));
     SetIntProperty(Property->GetName(), Value);
 }
avatar image intoxicat3 Nov 23 '16 at 07:19 PM

but how to get properties values from UStructProperty?

avatar image AntimonyFox May 04 '17 at 02:12 AM

Perhaps this answer can help: Set/Get UProperty inside of USTRUCT directly

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question