Help with variable changing value "by itself" between the constuctor call and BeginPlay()

I can’t figure out what’s wrong, when I print the same variables ySiz and zSiz, without editing it, it gives different values.
Before BeginPlay() it gives the correct values (3 and 3) while inside the BeginPlay() it gives (-8484849(a nimber kinda like this) and 0).
I have no idea about what’s wrong, I’m really stuck here.
Can anybody help? Thanks a lot!

Here are the two classes BlockStructure EditableWood

If it’s a uproperty, then it’s been deserialised between the constructor and begin play calls.

I tried to remove all uproperties but the issue persists, also I replaced all int variables I missed with int32, but that still doesn’t solve the issue

UBlockStructure* blockStructure;

This should be a uproperty.
Any unreal based class (USomething, ASomething, etc) should be uproperty or it will eventually be garbage collected by unreal. Accessing garbage collected data could potentially work but give bogus results.
Non unreal/classes like int, float, FString, FVector (structs) are fine without uproperty.

Also you could bind all your values to a vector and then print that for ease of typing, if ya wanted.
FVector(xSiz, ySiz, zSiz).ToString()

Thanks a lot, this solved the issue!
So even tarrays should be a uproperty?
I really didn’t know about this but it makes sense. For future references, I now found the proper documentation here.

I would assume TArray depends on it’s contents, be it int or UObjects.
Basically whether the class derives from UObject at some point and can be an object in game, or if it’s just used for data like strings, ints, structs, etc.
I’m no professional on the subject, just a guy who ran into similar problems a while ago. :slight_smile:

Thanks again for the help!

Great thread. I was having the same issue the other day. Thanks!