Getting object's float values via TIterator

I’m iterating through an object’s properties, storing them in a TArray by name and at the same time storing the associated value in a TArray.
However, I’m getting this output using my UE_LOG feedback:

[2015.06.02-18.56.58:990][153]LogTemp:Warning: Getting float property from GravityMagnitudeDuringGlide, value is -107374176.000000:

[2015.06.02-18.56.58:990][153]LogTemp:Warning: Getting float property from GravityCap, value is -107374176.000000:

[2015.06.02-18.56.58:991][153]LogTemp:Warning: Getting float property from FlapHoldTimeUntilGlide, value is -107374176.000000:

[2015.06.02-18.56.58:999][153]LogTemp:Warning: Reading back property names from TArrays, Property:GravityMagnitudeDuringGlide, Value: -107374176.000000

[2015.06.02-18.56.58:999][153]LogTemp:Warning: Reading back property names from TArrays, Property:GravityCap, Value: -107374176.000000

[2015.06.02-18.56.58:999][153]LogTemp:Warning: Reading back property names from TArrays, Property:FlapHoldTimeUntilGlide, Value: -107374176.000000

So I know the TArray emplace is working fine, except the float looks like an uninitialized(?) value…

I tried it in the object initializer, postinitializer, I tried it using ThisLevel->bIsVisible as a condition inside the tick and it always returns the same values, so I’m guessing there’s something I’m missing here.

Anyway, this is my code:

	FString FObjectName = Object->GetName();
	UE_LOG( LogTemp , Warning , TEXT( "Getting float properties from %s"), *FObjectName  );
	int ForLoopCounter = 0;
	for (TFieldIterator<UFloatProperty> Property( Object->GetClass() ); Property; ++Property)
		uint32 IndexPosition = ForLoopCounter;
		uint32 SizeOfUint32 = sizeof( uint32 );
		bool Result = ForLoopCounter <= MAXUINT32;
		check( Result );

		float VariableValue;
		Property->GetFloatingPointPropertyValue( &VariableValue );

		FString VariableName = Property->GetNameCPP();
		ThisObjectFloatValuesByIndex.Emplace( VariableValue );
		UE_LOG( LogTemp , Warning , TEXT( "Getting float property from %s, value is %f:" ) , *VariableName, VariableValue );
	for (uint32 i = 0; i < ((uint32)ThisObjectFloatPropertyNames.Num()); i++)
		UE_LOG( LogTemp , Warning , TEXT( "Reading back property names from TArrays, Property:%s, Value: %f" ) , *ThisObjectFloatPropertyNames[i] , ThisObjectFloatValuesByIndex[i]);



Ah ok, looks like I found out the proper way to do it, although I don’t fully understand why.
If anyone can explain this to me, that’d be awesome.

My GUESS is that value is actually the name of the property…? I’ll have to do some reading on containers.

The problematic bit was

Property->GetFloatingPointPropertyValue( &VariableValue );

The correct way is:

VariableValue = Property->GetPropertyValue_InContainer( Object );

I’d love to hear any insight about why this worked as opposed to the first attempt.


I think I did figure out why, there wasn’t a proper instance of the object in question created to properly get any real addresses to the property values in question.